comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Ada.Exceptions could be 'pragma Preelaborate' ?
Date: 1998/10/30
Date: 1998-10-30T00:00:00+00:00	[thread overview]
Message-ID: <wccn26dvfgi.fsf@world.std.com> (raw)
In-Reply-To: u90hxkjhl.fsf@gsfc.nasa.gov

Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:

> Currently, Ada.Exceptions has no elaboration pragma, and thus any unit
> that 'withs' Ada.Exceptions cannot have 'pragma Preelaborate'. This is
> a pain; I'm building a nice library, everything is either Pure or
> Preelaborate, but then I start adding nice error messages to my
> exceptions, and I have to get rid of the pragmas. I started replacing
> Preelaborate with Elaborate_Body, and got some circular elaboration
> problems.

Yeah, that's a problem.  Similarly, if you want to put debugging
print-outs into a pragma-Pure package, you can't.

Here's a way to cheat, that usually works: You want to call some package
for Pure or Preelab code.  Declare another package with the same
functionality, and give it a pragma Pure.  Declare the original thing
with "pragma Export(Ada,...);" on all the procedures, and declare the
other one as "pragma Import(Ada, ...);".  This allows this package to
call the other one, without doing a "with" of it.

But be careful you don't call the Pure thing before the impure one has
been elaborated -- the run-time checks won't catch such an error!

IMHO such cheating is not "immoral", so long as it's just debugging
output we're talking about.  But you need to be careful that you don't
waste time debugging the debugging code.

> So, is there a reason Ada.Exceptions can't be Preelaborate? nothing in
> the public spec violates a rule; do most implementations require
> something that does?

Yes, I would expect implementations might want to do some
non-preelaborable stuff in Ada.Exceptions.

- Bob

P.S. Pragma Preelaborate is one of the features of Ada 95 I'm least
happy with -- don't get me started...  ;-)
-- 
Change robert to bob to get my real email address.  Sorry.




  parent reply	other threads:[~1998-10-30  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-30  0:00 Ada.Exceptions could be 'pragma Preelaborate' ? Stephen Leake
1998-10-30  0:00 ` Tucker Taft
1998-10-30  0:00 ` Robert A Duff [this message]
1998-10-31  0:00   ` dewar
1998-11-04  0:00   ` Michel Gauthier
1998-11-04  0:00     ` dewar
replies disabled

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