From: laoxhai <laoXhai@ix.netcom.com>
Subject: Re: Package with initialization only
Date: 1999/07/22
Date: 1999-07-22T15:08:31-05:00 [thread overview]
Message-ID: <7n7tnv$qg0@dfw-ixnews8.ix.netcom.com> (raw)
In-Reply-To: 379728EA.5593E00E@pwfl.com
In article <379728EA.5593E00E@pwfl.com>,
Marin David Condic <condicma@bogon.pwfl.com> wrote:
>In the embedded world, elaboration can sometimes cause serious troubles.
>For example, in an application where the program begins execution in
>EEPROM and has to copy itself to RAM before it can start writing to
>memory, elaboration can be a problem. I've even had trouble with
>compilers that wanted to dynamically initialize static constants at
>elaboration (I guess to simplify the case where a constant might have a
>dynamically determined value) which is really a bad idea if you want to
>locate the constants in EEPROM.
Geoff Mendal suggested an interesting approach to this problem a
long time ago. Target elaboration by making problematic packages
generic. Then, no elaboration will occur until instantiation. For
example,
generic
package Bit_Twirler is
type Bits is ...
procedure Twirl(The_Bits : in out Bits);
-- Lots of other good stuff
end Bit_Twirler;
with Bit_Twirler;
with A, B, C, D, E, G, H;
procedure Data_Sloshing is
-- declare lots of variables, etc.
begin
declare
package BT is new Bit_Twirler;
-- BT only elaborates here
Local_Bits : BT.Bits;
begin
BT.Twirl(The_Bits => Local_Bits);
end;
end Data_Sloshing;
Using this technique, there is absolutely no question of where the
with'd unit will first elaborate, no question of its scope, and no
issues related to where it can be visible. This is a little bit of
overkill, but has worked out well in a few Ada 83 projects where a
large number of packages needed well defined elaboration.
Richard Riehle
richard@adaworks.com
http://www.adaworks.com
next prev parent reply other threads:[~1999-07-22 0:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-21 0:00 Package with initialization only Gautier
1999-07-21 0:00 ` Gautier de Montmollin
1999-07-21 0:00 ` Robert A Duff
1999-07-21 0:00 ` Ted Dennison
1999-07-21 0:00 ` Samuel T. Harris
1999-07-21 0:00 ` David C. Hoos, Sr.
1999-07-22 0:00 ` David Kristola
1999-07-22 0:00 ` Ted Dennison
1999-07-22 0:00 ` Samuel T. Harris
1999-07-22 0:00 ` Marin David Condic
1999-07-22 0:00 ` laoxhai [this message]
1999-07-21 0:00 ` Martin C. Carlisle
1999-07-22 0:00 ` Robert I. Eachus
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox