From: Adam Beneschan <adam@irvine.com>
Subject: Re: Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns.
Date: Tue, 23 Apr 2013 09:00:45 -0700 (PDT)
Date: 2013-04-23T09:00:45-07:00 [thread overview]
Message-ID: <f91ac67c-02c9-43fd-982c-a58567aa9a1b@googlegroups.com> (raw)
In-Reply-To: <97967083-d21d-4de2-aeb8-76d0d5818993@googlegroups.com>
On Monday, April 22, 2013 11:27:09 AM UTC-7, Shark8 wrote:
> I recently ran into unexpected behavior in the differences between a normal return and an extended return [in GNAT]: namely an extended return used to generate items in an array of tasks will *ALWAYS* execute in a sequential manner whereas the array generated with an expression-function or normal return is executed simultaneously.
>
> Is there some subtle difference in the extended return that I'm unaware of? (Is this a bug?)
OK, I think I've figured it out--egilhh was on the right track. The
key rules are 7.6.1(4), "For the finalization of a master, dependent
tasks are first awaited, as explained in 9.3", and 9.3(2):
"If the task is created by the evaluation of an allocator for a given
access type, it depends on each master that includes the elaboration
of the declaration of the ultimate ancestor of the given access type."
The language here may be a bit sloppy, since for an anonymous access
type, I'm not sure there's any such thing as "the declaration of
... [a] given access type". However, if this is interpreted as "the
declaration that causes the access type to be defined", then for
Make_ER, the declaration referred to is the extended return object
declaration, because that's the type that the allocator returns:
Return Result : Not Null Access Testing:= New Testing(New String'(Input));
However, for Make_EF and Make_NR, the declaration is the function
declaration. In Make_ER, the master that elaborates the extended
return object declaration (and therefore the anonymous access type
declaration) is the body of Make_ER. (For the other cases, the
master that elaborates the declaration is the Experiment procedure.)
The upshot of all this is that, by 7.6.1(4) and 9.3(2), in Make_ER,
the task created by the allocator *depends* *on* the body of Make_ER,
and therefore the body of Make_ER cannot complete until the task has
completed. That should be enough to explain the results.
The moral: Whether or not you think anonymous access types are evil,
anonymous access types to *tasks* definitely can have some surprising
consequences (because of the task termination and dependency rules),
and should be avoided.
-- Adam
next prev parent reply other threads:[~2013-04-23 16:00 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 [this message]
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
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