comp.lang.ada
 help / color / mirror / Atom feed
* Preelaborable generic body: question
@ 2004-11-30  2:05 Adam Beneschan
  2004-11-30  2:43 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Beneschan @ 2004-11-30  2:05 UTC (permalink / raw)


In this example:

generic
   x1: integer;
package pak2 is
   pragma Preelaborate;
   pragma Elaborate_Body;
end pak2;

package body pak2 is
   x2: integer := x1;
end pak2;

My reading is that 10.2.1(10) makes this illegal, because it's
possible to instantiate pak2 with an actual for "x1" that would cause
the declaration of x2 to perform an action that 10.2.1(6-7) makes
nonpreelaborable.  (You could instantiate pak2 with an actual that
contains a function call or the name of an object, e.g.)

Is my reading correct?

                                   -- thanks, Adam



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

* Re: Preelaborable generic body: question
  2004-11-30  2:05 Preelaborable generic body: question Adam Beneschan
@ 2004-11-30  2:43 ` Stephen Leake
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Leake @ 2004-11-30  2:43 UTC (permalink / raw)
  To: comp.lang.ada

adam@irvine.com (Adam Beneschan) writes:

> In this example:
> 
> generic
>    x1: integer;
> package pak2 is
>    pragma Preelaborate;
>    pragma Elaborate_Body;
> end pak2;
> 
> package body pak2 is
>    x2: integer := x1;
> end pak2;
> 
> My reading is that 10.2.1(10) makes this illegal, because it's
> possible to instantiate pak2 with an actual for "x1" that would cause
> the declaration of x2 to perform an action that 10.2.1(6-7) makes
> nonpreelaborable.  (You could instantiate pak2 with an actual that
> contains a function call or the name of an object, e.g.)

Interesting. ALRM 1.a tends to support your view:

1.a
          The legality of an instance should be determinable without
          looking at the generic body. Likewise, the legality of a
          generic body should be determinable without looking at any
          instances. 

However, 12.3 (21) says (about instantiating a generic):

For the evaluation of a generic_association the generic actual
parameter is evaluated. 

ALRM 12.4 (1.a) says:

1.a
          A generic formal object of mode in is like a constant
          initialized to the value of the
          explicit_generic_actual_parameter.

So the action of evaluating your hypothetical function is at the point
of elaborating the declaration of x1, not in the body of pak2. So it
is the instantiation that is not preelaborable, not pak2 itself. 

Hmm. On the other hand, I think the declaration of x1 is in the spec
of the instance of pak2, so that makes any generic formal object
non-preelaborable. I hope that's not right!

But I'm not really a language lawyer :).

-- 
-- Stephe




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

end of thread, other threads:[~2004-11-30  2:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-30  2:05 Preelaborable generic body: question Adam Beneschan
2004-11-30  2:43 ` Stephen Leake

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