comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: generic package dilemma
Date: 1999/11/19
Date: 1999-11-19T00:00:00+00:00	[thread overview]
Message-ID: <812mr2$u4$1@nnrp1.deja.com> (raw)
In-Reply-To: 3832e27f_1@news1.prserv.net

In article <3832e27f_1@news1.prserv.net>,
  "Matthew Heaney" <matthew_heaney@acm.org> wrote:
> > -- main procedure
> > with gen_pack1;
> > with gen_pack4;
>
> You should always elaborate packages that you instantiate:
>
> pragma Elaborate (Gen_Pack1);
> pragma Elaborate (Gen_Pack4);

This is quite incorrect advice in two respects.

First: you only need to worry about elaboration if you are
doing the instantiation in elaboration code, which is not
the case in the example to which you are responding.

Second: if (unlike this case) you are doing an instantiation
in elaboration code, then *always* use Elaborate_All in
Ada 95. The number of cases where Elaborate is appopriate
is very small. I actually am the one responsible for the
examples that caused pragma Elaborate to be "rescued" from
Annex J, but basically it is only poorly written legacy
code that needs pragma Elaborate as opposed to Elaborate_All.

The simple usage rule is NEVER use pragma Elaborate, ALWYAS
use pragma Elaborate_All instead.

But to repeat, neither pragma is appropriate in the case where
the instantiations occur within a procedure!

Either the procedure is called at elaboration time or it is not.
If it is not, then there is nothing to worry about. If it is
called at elaboration problem, then the burden is on the caller
to do an Elaborate_All, which will ensure that the generics are
elaborated before they are instantiated.

Elaboration stuff is tricky!


Sent via Deja.com http://www.deja.com/
Before you buy.




      parent reply	other threads:[~1999-11-19  0:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-17  0:00 generic package dilemma Riyaz Mansoor
1999-11-17  0:00 ` Matthew Heaney
1999-11-17  0:00   ` Mats Weber
1999-11-17  0:00     ` Matthew Heaney
1999-11-18  0:00       ` Robert A Duff
1999-11-18  0:00         ` Matthew Heaney
1999-11-18  0:00       ` Mats Weber
1999-11-18  0:00         ` Matthew Heaney
1999-11-19  0:00           ` Mats Weber
1999-11-19  0:00             ` Matthew Heaney
1999-11-19  0:00               ` Mats Weber
1999-11-22  0:00                 ` Robert Dewar
1999-11-22  0:00                   ` Mats Weber
1999-11-22  0:00                     ` Robert A Duff
1999-11-23  0:00                       ` Robert Dewar
1999-12-01  0:00                       ` Robert I. Eachus
1999-12-01  0:00                         ` Robert I. Eachus
1999-11-22  0:00                   ` Larry Kilgallen
1999-11-23  0:00                     ` Robert Dewar
1999-11-22  0:00                   ` Robert A Duff
1999-11-23  0:00                     ` Robert Dewar
1999-11-29  0:00                       ` Robert A Duff
1999-12-01  0:00                         ` Robert Dewar
1999-12-01  0:00                       ` Robert A Duff
1999-12-02  0:00                         ` Mats Weber
1999-12-03  0:00                           ` Robert Dewar
1999-12-03  0:00                             ` Ted Dennison
1999-12-04  0:00                               ` Robert Dewar
1999-12-03  0:00                             ` Robert A Duff
1999-12-06  0:00                               ` Robert Dewar
1999-11-22  0:00                   ` Mats Weber
1999-11-22  0:00                     ` Bryce Bardin
1999-11-23  0:00                     ` Robert Dewar
1999-11-19  0:00               ` Robert Dewar
1999-11-19  0:00                 ` Matthew Heaney
1999-11-20  0:00                   ` Mats Weber
1999-11-19  0:00                 ` Robert I. Eachus
1999-11-22  0:00                   ` Robert Dewar
1999-11-22  0:00                     ` Matthew Heaney
1999-11-19  0:00             ` Vladimir Olensky
1999-11-19  0:00       ` Robert Dewar
1999-11-18  0:00   ` Riyaz Mansoor
1999-11-19  0:00     ` Robert Dewar
1999-11-19  0:00   ` Robert Dewar [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