From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,100eb0a59892e906 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!t54g2000hsg.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: How to pass around access types to interfaces? Date: Fri, 24 Oct 2008 06:55:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <4901be81$0$23607$4f793bc4@news.tdc.fi> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1224856514 5856 127.0.0.1 (24 Oct 2008 13:55:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 24 Oct 2008 13:55:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: t54g2000hsg.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2487 Date: 2008-10-24T06:55:14-07:00 List-Id: > > I assume this type declaration is in the main *procedure*. This > > means that the type has a local scope and life, which prevents > > converting its values to a more long-lived access type. Try > > declaring Concrete_Type in a package; that makes it live as long as > > the whole program, and should allow such conversions. > > Yeah, the declaration was in the main procedure. When moving it to a > package everything works like it's supposed to. Thanks for your help. > > I guess I have still a lot to learn about Ada. I was just thinking > about the lifetime of the object. It never occured to me that a type > also has a lifetime. This is one of the most complex areas of Ada; it defines the lifetime of both objects and types in terms of "accessibility levels" (RM 3.10.2). This explains the error message "type in allocator has deeper level than designated class-wide type". Types can have a limited life time since they can be declared inside a subprogram (or indeed in any block). -- Ludovic Brenta.