comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns.
Date: Tue, 23 Apr 2013 17:52:04 +0100
Date: 2013-04-23T17:52:04+01:00	[thread overview]
Message-ID: <lya9opdwaz.fsf@pushface.org> (raw)
In-Reply-To: f91ac67c-02c9-43fd-982c-a58567aa9a1b@googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> 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.

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.

With the original code (modified as in my previous post) the output is

   TEST_1:	Expression Function
   Bob starting.
   Steve starting.
   Dave starting.
   Joey starting.
   Joey	 0.163312241
   Dave	 0.177723214
   Steve 0.354075342
   Bob	 0.573863626

   TEST_2:	Normal Return Function
   Bob starting.
   Steve starting.
   Dave starting.
   Joey starting.
   Dave	 0.302558333
   Steve 0.427543312
   Bob	 0.457369596
   Joey	 0.469346672

   TEST_3:	Extended Return Function
   Bob starting.

whereas changing 'not null access Testing' to a named access type
'Testing_P'

gives

   TEST_1:	Expression Function
   Bob starting.
   Steve starting.
   Dave starting.
   Joey starting.

   TEST_2:	Normal Return Function
   Bob starting.
   Steve starting.
   Dave starting.
   Joey starting.

   TEST_3:	Extended Return Function
   Bob starting.
   Steve starting.
   Dave starting.
   Joey starting.

   Terminating.
   Joey	 0.030557213
   Bob	 0.052638587
   Steve 0.076554827
   Bob	 0.104827218
   Bob	 0.122844748
   Dave	 0.315774351
   Dave	 0.446240813
   Joey	 0.512601733
   Joey	 0.560874224
   Steve 0.698063731
   Dave	 0.702636242
   Steve 0.852463245

By the way, what's the significance of 'constant' in 'not null access
constant Testing'?

> 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.

This.



  reply	other threads:[~2013-04-23 16:52 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 [this message]
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