comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Elaboration Question
Date: Fri, 2 Jan 2015 16:16:43 -0600
Date: 2015-01-02T16:16:43-06:00	[thread overview]
Message-ID: <m875cc$fb$1@loke.gir.dk> (raw)
In-Reply-To: lywq55pqej.fsf@pushface.org

"Simon Wright" <simon@pushface.org> wrote in message 
news:lywq55pqej.fsf@pushface.org...
> Hubert <herrdoktor@fumanchu.com> writes:
...
>> So may question is, is it better to just leave those variables
>> unitialized and then initialize them later for instance:
>>
>> A : Integer;
>>
>> PROCEDURE Initialize IS
>> BEGIN
>>    A:= 0;
>> END Initialize;
>>
>> Would that be generally better?
>
> I would say not. There might, after all, be a chain of Initialize calls
> required; very complicated to manage.

I agree. Plus you have the possibility of forgetting to call Initialize for 
some package, in which case weird things probably will happen.

Having said that, it's not always practical to get packages to elaborate in 
a particular order. If initialization is significant, it may make sense to 
use an explicit routine. For instance, in Janus/Ada, temporary files have to 
be read in a particular order, so we ended up using Initialize subprograms 
to do that (otherwise, packages that don't need to know about each other for 
any other reason end up coupled).

But for smaller initializing (like setting things to an empty state), I 
think you should always use elaboration.

                             Randy.




  reply	other threads:[~2015-01-02 22:16 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-02  3:27 Elaboration Question Hubert
2015-01-02  7:56 ` Simon Wright
2015-01-02 22:16   ` Randy Brukardt [this message]
2015-01-02 14:49 ` Brad Moore
2015-01-02 11:08   ` Mark Lorenzen
2015-01-02 13:35     ` David Botton
2015-01-02 15:11     ` sbelmont700
2015-01-02 21:57       ` Niklas Holsti
2015-01-06  2:33         ` Randy Brukardt
2015-01-06  8:17           ` Niklas Holsti
2015-01-06 20:06             ` Randy Brukardt
2015-01-03  9:45 ` Jean François Martinez
2015-01-03  9:50   ` Hubert
2015-01-03 18:43     ` Jean François Martinez
2015-01-04  1:57       ` Hubert
2015-01-04 12:05       ` Simon Wright
replies disabled

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