From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2485cb1936a0a4ec X-Google-Attributes: gid103376,public From: laoxhai Subject: Re: Package with initialization only Date: 1999/07/22 Message-ID: <7n7tnv$qg0@dfw-ixnews8.ix.netcom.com>#1/1 X-Deja-AN: 504133508 References: <37964947.5C95E5D1@hso.link.com> <7n65nl$1ru2@svlss.lmms.lmco.com> <379728EA.5593E00E@pwfl.com> Organization: Netcom X-NETCOM-Date: Thu Jul 22 3:08:31 PM CDT 1999 X-Inktomi-Trace: sji-ca-cache 932674100 99 209.109.234.219 (22 Jul 1999 20:08:20 GMT) Newsgroups: comp.lang.ada Date: 1999-07-22T15:08:31-05:00 List-Id: In article <379728EA.5593E00E@pwfl.com>, Marin David Condic 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