comp.lang.ada
 help / color / mirror / Atom feed
* Differences with/without .all
@ 2008-03-17 16:34 Alex R. Mosteo
  2008-03-17 20:42 ` Randy Brukardt
  2008-03-17 20:44 ` Ludovic Brenta
  0 siblings, 2 replies; 7+ messages in thread
From: Alex R. Mosteo @ 2008-03-17 16:34 UTC (permalink / raw)


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?

Alex.

[*] Exception possibly being constructions of this kind:
S.all'Access
which may be not equivalent to the original access type ("S'Type")?



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  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
  1 sibling, 0 replies; 7+ messages in thread
From: Randy Brukardt @ 2008-03-17 20:42 UTC (permalink / raw)


"Alex R. Mosteo" <devnull@mailinator.com> wrote in message
news:647ktoF2acjggU1@mid.individual.net...
> 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?

Looks like a bug to me. S.all is not a constant, and neither is
S(implicit.all). But S by itself is a constant. It's an easy mistake to
make, though, we used to have a very similar bug in Janus/Ada.

                         Randy.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  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
                     ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Ludovic Brenta @ 2008-03-17 20:44 UTC (permalink / raw)


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

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Eric Hughes @ 2008-03-17 21:17 UTC (permalink / raw)


On Mar 17, 2:44 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> 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."

The compiler is correct to reject the syntax.  The compiler has a
defect, though, in that it states an incorrect reason for rejecting
the syntax.

Eric



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  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
  2 siblings, 0 replies; 7+ messages in thread
From: Georg Bauhaus @ 2008-03-17 21:21 UTC (permalink / raw)


Ludovic Brenta wrote:
> Alex R. Mosteo writes:

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

I think the parameter profile of Some_Procedure isn't the
issue here as Some_Procedure is just a procedure of
Safe, but not an access to procedure.
 OTOH, S'Result points to a protected object and procedure
Some_Procedure is invoked with this (variable) object.

FWIW, another compiler is fine with the above.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  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
  2008-03-18 15:35     ` Adam Beneschan
  2 siblings, 1 reply; 7+ messages in thread
From: Adam Beneschan @ 2008-03-17 22:51 UTC (permalink / raw)


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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Differences with/without .all
  2008-03-17 22:51   ` Adam Beneschan
@ 2008-03-18 15:35     ` Adam Beneschan
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Beneschan @ 2008-03-18 15:35 UTC (permalink / raw)


On Mar 17, 3:51 pm, I <a...@irvine.com> wrote:

> [The main reason for 6.4(8) is: Suppose "Func" denotes an access-to-
> function type.

A bit sloppy of me... of course I meant "a value of an access-to-
function type".

                                 -- Adam

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





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-03-18 15:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2008-03-18 15:35     ` Adam Beneschan

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