comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Differences with/without .all
Date: Mon, 17 Mar 2008 15:51:34 -0700 (PDT)
Date: 2008-03-17T15:51:34-07:00	[thread overview]
Message-ID: <ca360845-14b0-4818-b15f-17e871b627ba@i12g2000prf.googlegroups.com> (raw)
In-Reply-To: 871w696pxz.fsf@ludovic-brenta.org

On Mar 17, 1:44 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> Alex R. Mosteo writes:
> > Hello people,
>
> > Gnat is giving me an error depending on if I use the .all
> > abbreviation or not.  I had the (unresearched) idea that there
> > should be no differences besides the aesthetic one[*], so I'm not
> > sure if gnat's wrong or I'm (guess what ;) )
>
> > One way or the other, I'd like to know the explanation. The
> > particular case that is giving me problems in GPL 2007 is:
>
> > protected type Safe;
> > type Safe_Access is access all Safe;
> > function S return Safe_Access;
>
> > S.Some_Procedure;
> > --  This fails with
> > --  Prefix of protected procedure or entry call must be variable
>
> > S.all.Some_Procedure;
> > --  This compiles and runs OK.
>
> > Your judgment?
>
> The compiler is correct.
>
> 6.4(9): "When there is an actual_parameter_part, the prefix can be an
> implicit_dereference of an access-to-subprogram value."
>
> In other words, in the absence of actual parameters, you must use an
> explicit_dereference, i.e. you must specify ".all".

Sorry, this rule doesn't apply.  First of all, it's 6.4(8), not 6.4(9)
[just to help anyone else who wants to look it up].  Second, this rule
applies when an access-to-subprogram value is involved in the
expression---and there are no access-to-subprogram values (or types)
in this example, just an access-to-protected-object.  Perhaps you're
confusing an "access-to-subprogram" with a "function that returns an
access type".

I think the compiler is wrong.

[The main reason for 6.4(8) is: Suppose "Func" denotes an access-to-
function type.  If you say Func(param,param,param), this results in an
implicit dereference of Func, and a call to the function pointed to by
Func.  But you cannot get a call to the function pointed to by Func if
there is no parameter list, even if the function type doesn't have any
parameters, or all parameters have defaults.  You must to say Func.all
in that case.]

                                  -- Adam






  parent reply	other threads:[~2008-03-17 22:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-17 16:34 Differences with/without .all Alex R. Mosteo
2008-03-17 20:42 ` Randy Brukardt
2008-03-17 20:44 ` Ludovic Brenta
2008-03-17 21:17   ` Eric Hughes
2008-03-17 21:21   ` Georg Bauhaus
2008-03-17 22:51   ` Adam Beneschan [this message]
2008-03-18 15:35     ` Adam Beneschan
replies disabled

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