comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen_leake@acm.org>
To: comp.lang.ada@ada-france.org
Subject: Re: Preelaborable generic body: question
Date: 29 Nov 2004 21:43:26 -0500
Date: 2004-11-29T21:43:26-05:00	[thread overview]
Message-ID: <mailman.154.1101782649.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <b4682ab7.0411291805.1579e730@posting.google.com>

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




      reply	other threads:[~2004-11-30  2:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-30  2:05 Preelaborable generic body: question Adam Beneschan
2004-11-30  2:43 ` Stephen Leake [this message]
replies disabled

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