comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Task entries and access to subprograms.
Date: Thu, 7 Apr 2005 18:23:17 -0500
Date: 2005-04-07T18:23:17-05:00	[thread overview]
Message-ID: <tIOdnR2ThMvFXcjfRVn-3g@megapath.net> (raw)
In-Reply-To: 4254E00C.30908@mailinator.com

"Alex R. Mosteo" <devnull@mailinator.com> 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.

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.







  parent reply	other threads:[~2005-04-07 23:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-06 10:25 Task entries and access to subprograms Alex R. Mosteo
2005-04-06 10:54 ` Adrien Plisson
2005-04-06 12:06 ` Dmitry A. Kazakov
2005-04-06 12:22   ` Alex R. Mosteo
2005-04-07  2:05 ` Jeffrey Carter
2005-04-07  7:23   ` Alex R. Mosteo
2005-04-07 14:01     ` Robert A Duff
2005-04-07 23:23     ` Randy Brukardt [this message]
2005-04-08  6:49       ` Alex R. Mosteo
2005-04-08 14:49         ` Robert A Duff
2005-04-08 15:23           ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox