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,42795ada22dedd1b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!i38g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Legal usage of downward closures Date: Thu, 16 Aug 2007 10:08:30 -0700 Organization: http://groups.google.com Message-ID: <1187284110.812863.280360@i38g2000prf.googlegroups.com> References: <1187280678.505830.294720@a39g2000hsc.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1187284111 24693 127.0.0.1 (16 Aug 2007 17:08:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 16 Aug 2007 17:08:31 +0000 (UTC) In-Reply-To: <1187280678.505830.294720@a39g2000hsc.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i38g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:1462 Date: 2007-08-16T10:08:30-07:00 List-Id: On Aug 16, 9:11 am, mala...@magic.fr wrote: > Hi, > > I have problems understanding the RAT05 section on downward closures. > > I thought that anonymous access to a sub-program, as parameter of a > sub-program, would prevent local copies and further usage out of > scope. > Surprisingly, the following example compiles an runs (on GNAT GPL > 2007). The assignment statements are illegal. Every "anonymous access type" definition defines its own type; therefore Acc1 and Arg don't have the same type, and neither of those types is the same as Acc2_Type. GNAT has a bug if it accepts them. Furthermore, this would be illegal due to accessibility level rules: Acc2 := Acc_Type(Arg); -- Adam > package Pack is > procedure Store (Arg : access procedure); > procedure Call; > end Pack; > > package body Pack is > Acc1 : access procedure; > type Acc_Type is access procedure; > Acc2 : Acc_Type; > > procedure Store (Arg : access procedure) is > begin > Acc1 := Arg; -- ILLEGAL > Acc2 := Arg; -- ILLEGAL > end Store; > procedure Call is > begin > Acc1.all; > Acc2.all; > end Call; > > end Pack;