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=-0.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLY autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e1c47fd1b76b1c05 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Task entries and access to subprograms. Date: Fri, 08 Apr 2005 08:49:58 +0200 Message-ID: <42562996.9010306@mailinator.com> References: <4253B917.5070800@mailinator.com> <4254E00C.30908@mailinator.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net BLlvmiXnysQAF3jmpBFo9QGrJp8kM8uTs4C6fAnWovwDb4DJU= User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:10331 Date: 2005-04-08T08:49:58+02:00 List-Id: Randy Brukardt wrote: > "Alex R. Mosteo" wrote in message > news:4254E00C.30908@mailinator.com... > >>Jeffrey Carter wrote: >> >>>Alex R. Mosteo wrote: >>> >>> >>>>type AInt is access all Integer; >>>>type Code is access procedure; >>> >>> >>>> entry Two (I : AInt); -- No complaint. Legal? >>> >>> >>>This was legal in Ada 83, and that wasn't changed by Ada 95. >>> >>> >>>> entry Four (C : Code); -- No complaint. >>> >>> >>>There's a difference between access parameters and parameters of an >>>access type. >> >>Yep. I just feel a bit disturbed when something with a so easy >>workaround is forbidden. > > > Workaround, yes. But these things aren't at all the same, which is obvious > if you think about all of the implications. (I know Bob has given the actual > reason for the rule, but his explanation is more for language lawyers.) > > Consider the two similar subprograms declared in a library package > specification: > > type Acc_Int is access Integer; > procedure One (P : Acc_Int); > procedure Two (A : access Integer); > > On the surface, these appear the same. But they have very different > accessibility rules. That's easy to see when you make a call: > > procedure Test is > Foo : aliased Integer; > begin > One (Foo'Access); -- Illegal! Fails accessibility check. > Two (Foo'Access); -- OK > end Test; > > Any accessibility checks needed will be done in the body of Two, while for > One, they're done at the point of the call. I see. One thing I've never fully understood (and I'm ashamed to admit it, since I've read and forgotten the rationale at least a couple of times) is why One (Foo'Access) is illegal in your example. This gives multiple headaches (say, using Unchecked_Access :)) in situations who are clearly void of risk. I think these rules have been somewhat relaxed in 0Y, to add to my confusion, but at least now I don't find so many unexpected failed checks. It may be simply that the "not null access" moves the check out as in your Two example, but I must reread it (both 95 and 0Y). Thanks! > > Bob's point is that the standard implementation of the accessibility check > won't work for an entry; and there is no other obvious > no-distributed-overhead implementation available, thus writing the anonymous > parameter with its complicated accessibility is prohibitied. (You could > implement the check with a fully dynamic accessibility level, but this would > have a cost on every scope entrance and exit, and that would be too much to > swallow.) > > Hope this makes it clear. (One could argue that the accessibility rules > shouldn't have been different, but that's water under the dam at this > point.) > > Randy. > > > >