comp.lang.ada
 help / color / mirror / Atom feed
* Defaults for formal subprogram
@ 2010-04-28  9:57 Maxim Reznik
  2010-04-28 10:31 ` AdaMagica
  0 siblings, 1 reply; 5+ messages in thread
From: Maxim Reznik @ 2010-04-28  9:57 UTC (permalink / raw)


Hi all

What clause of ARM does this code violate?

procedure Aaa is

   type Proc_Ptr is access procedure;

   X : Proc_Ptr;

   generic
      with procedure Bbb is X.all;
      -- aaa.adb:8:31: expect valid subprogram name as default
   package Pkg is
   end Pkg;

begin
   null;
end;



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

* Re: Defaults for formal subprogram
  2010-04-28  9:57 Defaults for formal subprogram Maxim Reznik
@ 2010-04-28 10:31 ` AdaMagica
  2010-04-28 10:53   ` Ludovic Brenta
  2010-04-28 21:12   ` Randy Brukardt
  0 siblings, 2 replies; 5+ messages in thread
From: AdaMagica @ 2010-04-28 10:31 UTC (permalink / raw)


> procedure Aaa is
>
>    type Proc_Ptr is access procedure;
>
>    X : Proc_Ptr;
>
>    generic
>       with procedure Bbb is X.all;
>       -- aaa.adb:8:31: expect valid subprogram name as default
>    package Pkg is
>    end Pkg;

AARM 12.6(5.b) The evaluation of the default_name takes place during
the elaboration of each instantiation that uses the default, as
defined in 12.3, “Generic Instantiation”.

So I don't see a problem.



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

* Re: Defaults for formal subprogram
  2010-04-28 10:31 ` AdaMagica
@ 2010-04-28 10:53   ` Ludovic Brenta
  2010-04-28 10:56     ` Ludovic Brenta
  2010-04-28 21:12   ` Randy Brukardt
  1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Brenta @ 2010-04-28 10:53 UTC (permalink / raw)


Christoph Grein wrote on comp.lang.ada:
> > procedure Aaa is
>
> >    type Proc_Ptr is access procedure;
>
> >    X : Proc_Ptr;
>
> >    generic
> >       with procedure Bbb is X.all;
> >       -- aaa.adb:8:31: expect valid subprogram name as default
> >    package Pkg is
> >    end Pkg;
>
> AARM 12.6(5.b) The evaluation of the default_name takes place during
> the elaboration of each instantiation that uses the default, as
> defined in 12.3, “Generic Instantiation”.
>
> So I don't see a problem.

I think this violates 12.6(3/2) and 12.6(4):

3/2 subprogram_default ::= default_name | <> | null
4    default_name ::= name

Here, you are trying to use an expression as opposed to a name.

--
Ludovic Brenta.



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

* Re: Defaults for formal subprogram
  2010-04-28 10:53   ` Ludovic Brenta
@ 2010-04-28 10:56     ` Ludovic Brenta
  0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Brenta @ 2010-04-28 10:56 UTC (permalink / raw)


On Apr 28, 12:53 pm, Ludovic Brenta <ludo...@ludovic-brenta.org>
wrote:
> Christoph Grein wrote on comp.lang.ada:
>
>
>
> > > procedure Aaa is
>
> > >    type Proc_Ptr is access procedure;
>
> > >    X : Proc_Ptr;
>
> > >    generic
> > >       with procedure Bbb is X.all;
> > >       -- aaa.adb:8:31: expect valid subprogram name as default
> > >    package Pkg is
> > >    end Pkg;
>
> > AARM 12.6(5.b) The evaluation of the default_name takes place during
> > the elaboration of each instantiation that uses the default, as
> > defined in 12.3, “Generic Instantiation”.
>
> > So I don't see a problem.
>
> I think this violates 12.6(3/2) and 12.6(4):
>
> 3/2 subprogram_default ::= default_name | <> | null
> 4    default_name ::= name
>
> Here, you are trying to use an expression as opposed to a name.

Ah but looking further I see 4.1(2):

name ::=
     direct_name | explicit_dereference
   | indexed_component | slice
   | selected_component | attribute_reference
   | type_conversion | function_call
   | character_literal

and 4.1(5): explicit_dereference ::= name.all

so your code now seems legal to me. So this is probably a compiler
bug.

--
Ludovic Brenta.



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

* Re: Defaults for formal subprogram
  2010-04-28 10:31 ` AdaMagica
  2010-04-28 10:53   ` Ludovic Brenta
@ 2010-04-28 21:12   ` Randy Brukardt
  1 sibling, 0 replies; 5+ messages in thread
From: Randy Brukardt @ 2010-04-28 21:12 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

"AdaMagica" <christoph.grein@eurocopter.com> wrote in message 
news:9ac3f3db-819c-4232-b580-30a67411dd70@c21g2000yqk.googlegroups.com...
>> procedure Aaa is
>>
>> type Proc_Ptr is access procedure;
>>
>> X : Proc_Ptr;
>>
>> generic
>> with procedure Bbb is X.all;
>> -- aaa.adb:8:31: expect valid subprogram name as default
>> package Pkg is
>> end Pkg;
>
>AARM 12.6(5.b) The evaluation of the default_name takes place during
>the elaboration of each instantiation that uses the default, as
>defined in 12.3, �Generic Instantiation�.
>
>So I don't see a problem.

I agree, I think this is legal as the language is written. I know from 
experience that most compilers have problems with dynamic subprogram names 
showing up in unusual contexts. For instance, the ARG decided to make such 
names illegal for the specification of stream attributes because of the near 
impossibility of writing anything useful with a dynamic name (most compilers 
didn't support it anyway).

But in this case, it seems as if it could be useful, so presumably it is 
just a compiler bug.

                          Randy.





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

end of thread, other threads:[~2010-04-28 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-28  9:57 Defaults for formal subprogram Maxim Reznik
2010-04-28 10:31 ` AdaMagica
2010-04-28 10:53   ` Ludovic Brenta
2010-04-28 10:56     ` Ludovic Brenta
2010-04-28 21:12   ` Randy Brukardt

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