comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Interresting difference in Normal-Returns/Expression-Functions and Extended-Returns.
Date: Fri, 3 May 2013 18:09:52 -0500
Date: 2013-05-03T18:09:52-05:00	[thread overview]
Message-ID: <km1g43$jra$1@munin.nbi.dk> (raw)
In-Reply-To: e7ef987b-3fdb-4b59-bfd5-918006cf1ce2@googlegroups.com

"Adam Beneschan" <adam@irvine.com> wrote in message 
news:e7ef987b-3fdb-4b59-bfd5-918006cf1ce2@googlegroups.com...
...
>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.

It might be useful to know that the accessibility of an anonymous access 
return type is the same as that of an access discriminant returned from a 
function. And this is what provides the "value" of these things: the 
user-defined dereferencing is built on access discriminants simply because 
they already had the correct accessibility. So we were able to get what we 
wanted (a very short-lived access value that can be dereferenced but cannot 
be copied in most circumstances) without inventing new rules.

This is where we put up the disclaimer (a-la Mythbusters): "Do not try this 
at home! The ARG are trained professionals and they barely know what they're 
doing! :-)"

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

This is generally good advice. There are a lot of different kinds of 
anonymous access types and they all act different; unless you know what your 
doing, you're going to get it wrong. For instance, the anonymous access type 
(AAT) of a component has the accessibility of the enclosing type (usually 
static); AAT of parameters is fully dynamic; AAT of a stand-alone object is 
almost fully dynamic (they don't allow shorter lifetimes), AAT of a function 
result depends on the point of call, and AAT of a discriminant depends on 
where it is used, including all of the above.

There is a good reason that 3.10.2 is known within the ARG as the "Heart of 
Darkness". :-) [This is now mentioned in the AARM: 3.10.2(3.b/3).]

                                               Randy.


                                -- Adam






  parent reply	other threads:[~2013-05-03 23:09 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
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 [this message]
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