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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.59.205 with SMTP id m13mr14178632qah.7.1367543495994; Thu, 02 May 2013 18:11:35 -0700 (PDT) X-Received: by 10.50.12.4 with SMTP id u4mr1353439igb.5.1367543495810; Thu, 02 May 2013 18:11:35 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!news.glorb.com!l3no533201qak.0!news-out.google.com!y6ni0qax.0!nntp.google.com!m7no542947qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 2 May 2013 18:11:35 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <97967083-d21d-4de2-aeb8-76d0d5818993@googlegroups.com> <03e84773-d616-4a46-8189-93ae4ab5fcbf@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns. From: Adam Beneschan Injection-Date: Fri, 03 May 2013 01:11:35 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:15306 Date: 2013-05-02T18:11:35-07:00 List-Id: On Wednesday, May 1, 2013 7:38:29 PM UTC-7, Randy Brukardt wrote: > On Tuesday, April 23, 2013 9:52:04 AM UTC-7, Simon Wright wrote: >=20 > > Yes, but there are other similar side effects: in the tests, OP wrote >=20 > > declare > > function Make(Input : in String) return not null access Testing > > renames Make_EF; > > > > P : constant array (Positive range <>) of > > not null access constant Testing:=3D > > ( Make("Bob"), Make("Steve"), Make("Dave"), Make("Joey") ); > > begin > > null; > > end TEST_1; >=20 > > and the code doesn't exit the declare block until all the tasks have > > completed. >=20 > Adam says: > > I don't see a language reason for that. OK, after some discussion on Ada-Comment (mostly me being straightened out = by Randy), I've found out what the intent of the rules was supposed to be. = I didn't really understand them before. The RM defines accessibility leve= ls, which correspond with masters; the intent was that when a task is alloc= ated using an anonymous access type, the master on which the task depends i= s supposed to be the master "corresponding" with the accessibility level (9= .3(2) isn't clear about this, but that was the intent). And (as Egil point= ed out) the accessibility level of anonymous access function results has be= en changed in Ada 2012--it now gets its level from the point where the func= tion is called. So that explains the behavior. Based on what I now understand, I think Shark8's original example is misbeh= aving. 6.5(5.3) says that the accessibility level of an anonymous-access i= n an extended return statement is the same as the accessibility level of th= e function result; and since this seems to determine what masters the alloc= ated tasks depend on, the master for the task allocated by Make_ER should b= e the same as the one in Make_NR and (I think) for Make_EF. So it's a comp= iler bug that they're behaving differently. I still think that anonymous access types should only be used when necessar= y, since there are special accessibility level rules for anonymous access t= ypes that have some surprising consequences. There may be cases where it's= beneficial to take advantage of those special rules. But one should not u= se anonymous access types just because "hey, Ada lets us do it now and I ca= n just throw in a pointer without having to think up a type name, like C pr= ogrammers get to do!". A good rule might be "don't use anonymous access ty= pes unless you've read 3.10.2 and understand it thoroughly." (OK, that was= a joke.) -- Adam