comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: AQ&S Guidance on pragma Elaborate_Body
Date: 1997/04/23
Date: 1997-04-23T00:00:00+00:00	[thread overview]
Message-ID: <E940xu.62B@world.std.com> (raw)
In-Reply-To: dewar.861642821@merv


In article <dewar.861642821@merv>, Robert Dewar <dewar@merv.cs.nyu.edu> wrote:
>Robert Duff said
>
><<If you're willing to live with some restrictions, and some complicated
>(slow?) processing at link time, you could dispense with all
>elaboration-control pragmas, and have the link phase determine an
>elaboration order that's guaranteed to not raise Program_Error.  But
>note that some of these pragmas (Pure, especially) have purposes other
>than just elaboration order.>>
>
>No, that's quite wrong. There are many things that can place restrictions
>on the order of elaboration.

But my assertion was that one could be rid of Program_Errors due to
calling subprograms before they've been elaborated.  That's certainly
true.  The link-time processing would have to walk the call graph, and
make sure every subprogram gets elaborated before it might be called.
This is complex, and perhaps slow, and would make some (fairly obscure)
legal programs illegal.

I admit that your example shows a case where you want to control
elaboration order, which has nothing to do with the predefined
Program_Error checks.  Is that something the language should help you
with?  I'm not sure.

It seems to me that elaboration order should not be implementation
dependent -- the main problem with the current Ada rules is that you can
port code (or simply recompile with a new version of your compiler) and
get a P_E that didn't used to happen.

But your example seems questionable to me.  (See below.)

>Suppose we have a package Glorp that has several procedures including
>Thunk, Boggle, and Glub. In the comments of package Glorp, we find the
>comment:
>
>-- WARNING: It is essential to call Thunk before calling Boggle. If you
>-- fail to do this, all subsequent calls to Glub will raise the Glob-Glob
>-- exception or otherwise malfunction. Clients of Glorp are responsible for
>-- obeying this rule, since no check is made (a check would introduce too
>-- much overhead).

OK, but tell us why Glorp doesn't simply call Thunk in its elaboration?
I mean, the whole point of having elaboration is to get stuff
initialized, and it should be Glorp's responsibility to do that.

I will admit that no reasonable Ada implementation will understand the
above comment.    ;-)

>Now, suppose we have two clients of Glorp, Jabber and Wocky. The elaboration
>code of Jabber calls Thunk, and the elaboration code of Wocky calls Boggle.
>
>Well now it is essential that Jabber is elaborated before Wocky, and no
>static analysis of the program code can determine this, and a pragma
>Elaborate is required.
>
>And if you think this is just theoretical, think again, there are
>instantiations of the names above in the SGI GNAT runtime library, and
>when we installed some new clever elaboration stuff (a bit like Bob
>proposes, but more effective, and easier to understand), the binder
>chose a much better elaboration order, much more clearly guaranteed
>to prevent Program_Error, but unfortunately wrong (of course this is
>a bug in the runtime, there is a missing pragma Elaborate).

But wouldn't the runtime be simpler if each package took care of its own
initialization?

>It is quite true that you can guarantee absence from Program_Error for a wide
>variety of programs automatically, and version 3.10 of GNAT does that. 

That's all I was asserting.

>...BUT
>it is far from true that this means that you could "dispense with all
>elaboration-control pragmas".

You quote me out of context -- there's a ", and have the link phase
determine an elaboration order that's guaranteed to not raise
Program_Error." there.  That's all I meant, although the more general
situation is interesting from a language design point of view.

- Bob




  reply	other threads:[~1997-04-23  0:00 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-18  0:00 AQ&S Guidance on pragma Elaborate_Body JP Thornley
1997-04-18  0:00 ` Robert A Duff
1997-04-21  0:00   ` Michael F Brenner
1997-04-22  0:00     ` Robert A Duff
1997-04-18  0:00 ` Robert Dewar
1997-04-19  0:00   ` Michael Paus
1997-04-19  0:00     ` Robert A Duff
1997-04-21  0:00       ` Robert Dewar
1997-04-23  0:00         ` Robert A Duff [this message]
1997-04-23  0:00           ` Robert Dewar
1997-04-24  0:00             ` Robert A Duff
1997-04-24  0:00               ` Robert Dewar
1997-04-24  0:00                 ` Robert Dewar
1997-04-25  0:00                   ` Robert A Duff
1997-04-25  0:00                 ` Mats Weber
1997-04-25  0:00                   ` Robert I. Eachus
1997-04-26  0:00                     ` Nick Roberts
1997-04-26  0:00                       ` Robert Dewar
1997-04-28  0:00                         ` Robert I. Eachus
1997-04-29  0:00                           ` Robert Dewar
1997-04-29  0:00                             ` Robert I. Eachus
1997-04-27  0:00                   ` Robert Dewar
1997-04-28  0:00                     ` Mats Weber
1997-04-29  0:00                     ` Redefinition of "=", elaboration and learning Ada Mats Weber
1997-04-29  0:00                       ` Robert A Duff
1997-04-30  0:00                         ` Mats Weber
1997-04-26  0:00                 ` AQ&S Guidance on pragma Elaborate_Body Nick Roberts
1997-04-26  0:00                   ` Robert Dewar
1997-04-24  0:00           ` Mats Weber
1997-04-24  0:00             ` Robert A Duff
1997-04-24  0:00               ` Robert Dewar
1997-04-25  0:00             ` Robert Dewar
1997-04-20  0:00     ` Robert Dewar
1997-04-21  0:00     ` Michael F Brenner
1997-04-23  0:00       ` Robert Dewar
1997-04-24  0:00         ` Laurent Guerby
1997-04-24  0:00         ` Matthew Heaney
1997-04-24  0:00           ` Jon S Anthony
1997-04-24  0:00             ` Matthew Heaney
1997-04-26  0:00               ` Robert Dewar
1997-04-26  0:00                 ` Matthew Heaney
1997-04-27  0:00                   ` Robert Dewar
1997-04-29  0:00                     ` John G. Volan
1997-04-29  0:00                       ` Matthew Heaney
1997-04-30  0:00                         ` Jon S Anthony
1997-05-01  0:00                         ` John G. Volan
1997-05-02  0:00                           ` Booch "forms" and child packages [was: AQ&S Guidance on pragma Elaborate_Body] John G. Volan
1997-05-02  0:00                         ` AQ&S Guidance on pragma Elaborate_Body John G. Volan
1997-04-26  0:00               ` Nick Roberts
1997-04-26  0:00                 ` Matthew Heaney
1997-04-26  0:00                 ` Robert A Duff
1997-04-25  0:00             ` Robert Dewar
1997-04-24  0:00           ` Robert A Duff
1997-04-24  0:00           ` Robert Dewar
1997-04-25  0:00           ` Michael F Brenner
1997-04-26  0:00             ` Nick Roberts
1997-04-20  0:00 ` Doug Smith
1997-04-20  0:00   ` Robert Dewar
1997-04-21  0:00     ` Matthew Heaney
1997-04-21  0:00       ` Robert A Duff
1997-04-21  0:00         ` Robert Dewar
1997-04-22  0:00           ` Robert A Duff
1997-04-24  0:00             ` Robert Dewar
1997-04-21  0:00         ` Matthew Heaney
1997-04-21  0:00           ` Robert A Duff
1997-04-21  0:00           ` Matthew Heaney
1997-04-22  0:00             ` Mats Weber
1997-04-22  0:00             ` Robert A Duff
1997-04-22  0:00               ` Matthew Heaney
1997-04-22  0:00                 ` Robert A Duff
1997-04-22  0:00                   ` Matthew Heaney
1997-04-23  0:00                     ` Robert A Duff
1997-04-24  0:00                       ` Matthew Heaney
1997-04-24  0:00                         ` Robert A Duff
1997-04-25  0:00                       ` Robert Dewar
1997-04-23  0:00                     ` Robert Dewar
1997-04-24  0:00                 ` Robert Dewar
1997-04-24  0:00                   ` Robert A Duff
1997-04-23  0:00             ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-04-30  0:00 W. Wesley Groleau (Wes)
1997-04-30  0:00 ` Robert I. Eachus
replies disabled

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