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,cf75272301f10c97 X-Google-Attributes: gid103376,public From: Robert A Duff Subject: Re: Ada.Exceptions could be 'pragma Preelaborate' ? Date: 1998/10/30 Message-ID: #1/1 X-Deja-AN: 406826482 Sender: bobduff@world.std.com (Robert A Duff) References: Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1998-10-30T00:00:00+00:00 List-Id: Stephen Leake 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.