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: a07f3367d7,344faf475a6f812a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.160.65 with SMTP id m1mr22846965qax.2.1366732845875; Tue, 23 Apr 2013 09:00:45 -0700 (PDT) X-Received: by 10.182.133.100 with SMTP id pb4mr652201obb.29.1366732845764; Tue, 23 Apr 2013 09:00:45 -0700 (PDT) Path: ef9ni12521qab.0!nntp.google.com!gp5no5274151qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 23 Apr 2013 09:00:45 -0700 (PDT) In-Reply-To: <97967083-d21d-4de2-aeb8-76d0d5818993@googlegroups.com> 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> 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: Tue, 23 Apr 2013 16:00:45 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-04-23T09:00:45-07:00 List-Id: On Monday, April 22, 2013 11:27:09 AM UTC-7, Shark8 wrote: > I recently ran into unexpected behavior in the differences between a norm= al 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 sequentia= l manner whereas the array generated with an expression-function or normal = return is executed simultaneously. >=20 > Is there some subtle difference in the extended return that I'm unaware o= f? (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:=3D 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