comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns.
Date: Thu, 2 May 2013 18:11:35 -0700 (PDT)
Date: 2013-05-02T18:11:35-07:00	[thread overview]
Message-ID: <e7ef987b-3fdb-4b59-bfd5-918006cf1ce2@googlegroups.com> (raw)
In-Reply-To: <klsjjd$qvv$1@munin.nbi.dk>

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:

> 
> > Yes, but there are other similar side effects: in the tests, OP wrote
> 
> > 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:=
> >     ( Make("Bob"), Make("Steve"), Make("Dave"), Make("Joey") );
> > begin
> >        null;
> > end TEST_1;
> 
> > and the code doesn't exit the declare block until all the tasks have
> > completed.
> 
> 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 levels, which correspond with masters; the intent was that when a task is allocated using an anonymous access type, the master on which the task depends is 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 pointed out) the accessibility level of anonymous access function results has been changed in Ada 2012--it now gets its level from the point where the function is called.  So that explains the behavior.

Based on what I now understand, I think Shark8's original example is misbehaving.  6.5(5.3) says that the accessibility level of an anonymous-access in an extended return statement is the same as the accessibility level of the function result; and since this seems to determine what masters the allocated tasks depend on, the master for the task allocated by Make_ER should be the same as the one in Make_NR and (I think) for Make_EF.  So it's a compiler bug that they're behaving differently.

I still think that anonymous access types should only be used when necessary, since there are special accessibility level rules for anonymous access types that have some surprising consequences.  There may be cases where it's beneficial to take advantage of those special rules.  But one should not use anonymous access types just because "hey, Ada lets us do it now and I can just throw in a pointer without having to think up a type name, like C programmers get to do!".  A good rule might be "don't use anonymous access types unless you've read 3.10.2 and understand it thoroughly."  (OK, that was a joke.)

                                -- Adam


  parent reply	other threads:[~2013-05-03  1:11 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 18:27 Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns Shark8
2013-04-22 19:13 ` Dmitry A. Kazakov
2013-04-22 20:11   ` Shark8
2013-04-23  6:15     ` Simon Wright
2013-04-23  7:35     ` Stephen Leake
2013-04-23  8:58     ` Dmitry A. Kazakov
2013-05-02  2:20     ` Randy Brukardt
2013-05-02  4:41       ` Shark8
2013-04-23  6:32 ` egilhh
2013-04-23 15:24   ` Adam Beneschan
2013-04-24  5:56     ` egilhh
2013-04-24 14:40       ` Adam Beneschan
2013-04-25  5:30         ` egilhh
2013-04-25  5:41           ` Shark8
2013-04-23 16:00 ` Adam Beneschan
2013-04-23 16:52   ` Simon Wright
2013-04-23 17:57     ` Adam Beneschan
2013-04-25  8:48       ` egilhh
2013-04-25 15:19         ` Adam Beneschan
2013-05-02  2:33         ` Randy Brukardt
2013-05-02  2:38       ` Randy Brukardt
2013-05-02 16:15         ` Adam Beneschan
2013-05-02 22:00           ` Randy Brukardt
2013-05-03  1:11         ` Adam Beneschan [this message]
2013-05-03  5:34           ` Simon Wright
2013-05-03  6:43           ` egilhh
2013-05-03 16:49             ` Adam Beneschan
2013-05-03 23:09           ` Randy Brukardt
2013-04-23 23:00     ` Shark8
2013-04-23 23:16       ` Adam Beneschan
2013-05-02  2:28   ` Randy Brukardt
2013-05-02 16:37     ` Adam Beneschan
2013-04-23 16:33 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox