comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: Constant elaboration order
Date: Thu, 6 Dec 2001 17:33:07 -0500
Date: 2001-12-06T17:33:07-05:00	[thread overview]
Message-ID: <u0vs9pabvlj2b4@corp.supernews.com> (raw)
In-Reply-To: 3c0fedf4$0$203$626a54ce@news.free.fr


"Thierry BERNIER" <tajz@free.fr> wrote in message
news:3c0fedf4$0$203$626a54ce@news.free.fr...
> Bonjour,
>
> Thanks to Ted and Robert, I just read the indicated chapter nn GNAT user's
> guide. Interesting and I will read it again with less noise around. May be
I
> will try to move some elaboration code to public packages's sub-program
and
> call them explicitely in the main program (as it is proposed in the GNAT
> UG).

Yes.  This is always a good idea:

package Subsystem is
   procedure Initialize;
...
end Subsystem;

And then in your main subprogram, simply call Subsystem.Initialize.

Lots of Ada programmers have gotten it into their heads that they should
stuff all kinds of hairy initialization code into the begin part of a
package body, but anything other than trivial initialization of package
state is a mistake.  Use the technique above.

This is especially relevant when you have tasks, because a task "activates"
when you hit the begin part of the body.  So if it tries to make a call to
another package, there's no guarantee that that other package has been
elaborated yet, and mayhem will ensue.

(Actually, I'm not sure what the exact rule is. Do all the library-level
tasks activate only after you hit the executable region of the main
subprogram?  Or does each task activate immediately following the
elaboration of its enclosing package?)






  reply	other threads:[~2001-12-06 22:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-30 21:59 Constant elaboration order Thierry BERNIER
2001-12-01  1:25 ` Ted Dennison
2001-12-01 16:43   ` Robert Dewar
2001-12-06 22:16     ` Thierry BERNIER
2001-12-06 22:33       ` Matthew Heaney [this message]
2001-12-07 14:34       ` Stephen Leake
replies disabled

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