comp.lang.ada
 help / color / mirror / Atom feed
  • * Re: Elaboration order
           [not found] <314701A1.469D@lfwc.lockheed.com>
           [not found] ` <1996Mar14.021345.9856@enterprise.rdd.lmsc.lockheed.com>
    @ 1996-03-15  0:00 ` Robert I. Eachus
      1996-03-15  0:00   ` Robert Dewar
      1996-03-18  0:00 ` Ken Garlington
                       ` (4 subsequent siblings)
      6 siblings, 1 reply; 66+ messages in thread
    From: Robert I. Eachus @ 1996-03-15  0:00 UTC (permalink / raw)
    
    
    In article <314829CD.4FA9@lfwc.lockheed.com> Ken Garlington <GarlingtonKE@lfwc.lockheed.com> writes:
    
      > Can I get a Program_Error on the initialization of X? If so, it
      > would seem like there would need to be a pragma Elaborate for
      > nearly every reference to every package exporting a subprogram!
    
       Yes, annd no.  IF you call a function from one package in the spec of
    some other package you certainly need a pragma Elaborate or pragma
    Elaborate_All.   If such a function (or a procedure) is used in the
    sequence of statements of the package body, or if you call subprograms
    declared earlier in the package there, or if you initialize objects in
    the package body using functions from some other package, you may need
    the pragmas as well.
    
       BUT, and this is what makes it so painless, either your program
    runs or you get PROGRAM_ERROR right off the bat, so leaving out a
    (potentially) required pragma Elaborate is pretty harmless.  (Unless
    you don't have a debugger that will tell you where the PROGRAM_ERROR
    came from.)  
    
       If you prefer, you can choose not to initialize objects in packages
    with function calls, and not to have sequences of statements in
    package bodies, but that is throwing the baby out with the bath water.
    
    --
    
    					Robert I. Eachus
    
    with Standard_Disclaimer;
    use  Standard_Disclaimer;
    function Message (Text: in Clever_Ideas) return Better_Ideas is...
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
  • * Re: Elaboration order
           [not found] <314701A1.469D@lfwc.lockheed.com>
           [not found] ` <1996Mar14.021345.9856@enterprise.rdd.lmsc.lockheed.com>
      1996-03-15  0:00 ` Robert I. Eachus
    @ 1996-03-18  0:00 ` Ken Garlington
      1996-03-18  0:00 ` Ted Dennison
                       ` (3 subsequent siblings)
      6 siblings, 0 replies; 66+ messages in thread
    From: Ken Garlington @ 1996-03-18  0:00 UTC (permalink / raw)
    
    
    Robert I. Eachus wrote:
    > 
    >    BUT, and this is what makes it so painless, either your program
    > runs or you get PROGRAM_ERROR right off the bat, so leaving out a
    > (potentially) required pragma Elaborate is pretty harmless.
    
    I have to tell you, a development philosophy that says, "Oh, well,
    if I make a mistake, I'll see an exception" rubs me the wrong way.
    Maybe I just don't have that Ada mindset...
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
  • * Re: Elaboration order
           [not found] <314701A1.469D@lfwc.lockheed.com>
                       ` (2 preceding siblings ...)
      1996-03-18  0:00 ` Ken Garlington
    @ 1996-03-18  0:00 ` Ted Dennison
      1996-03-19  0:00 ` Michel Gauthier
                       ` (2 subsequent siblings)
      6 siblings, 0 replies; 66+ messages in thread
    From: Ted Dennison @ 1996-03-18  0:00 UTC (permalink / raw)
    
    
    Ken Garlington wrote:
    > 
    > Robert I. Eachus wrote:
    > >
    > >    BUT, and this is what makes it so painless, either your program
    > > runs or you get PROGRAM_ERROR right off the bat, so leaving out a
    > > (potentially) required pragma Elaborate is pretty harmless.
    > 
    > I have to tell you, a development philosophy that says, "Oh, well,
    > if I make a mistake, I'll see an exception" rubs me the wrong way.
    > Maybe I just don't have that Ada mindset...
    
    Then I guess after 7 years of using Ada, I don't have the Ada mindset
    either.
    
    Again, the general rule is: don't call routines from other packages in
    package specs, package body declarations, or package body code. If for
    some reason you can't follow this rule, use a pragma elaborate. 
    
    While dependance on order of elaboration (w/o pragma elaborate) is not
    technicly erronious, I ding it every time I see it in a walkthrough.
    
    -- 
    T.E.D.          
                    |  Work - mailto:dennison@escmail.orl.mmc.com  |
                    |  Home - mailto:dennison@iag.net              |
                    |  URL  - http://www.iag.net/~dennison         |
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
  • * Re: Elaboration order
           [not found] <314701A1.469D@lfwc.lockheed.com>
                       ` (3 preceding siblings ...)
      1996-03-18  0:00 ` Ted Dennison
    @ 1996-03-19  0:00 ` Michel Gauthier
      1996-03-20  0:00 ` DenReimer
           [not found] ` <Do8JDv.A2v@world.std.com>
      6 siblings, 0 replies; 66+ messages in thread
    From: Michel Gauthier @ 1996-03-19  0:00 UTC (permalink / raw)
    
    
    In article <314EE48E.7F5A@escmail.orl.mmc.com>, Ted Dennison
    <dennison@escmail.orl.mmc.com> wrote:
    
    >>  Robert Dewar wrote:
    >>  > 
    >>  >  (snip)
    >>  (snip)
    >>  > This sounds VERY bogus, I would NEVER do this kind of initialization
    >>  > at elaboration time -- this is NOT what elaboratoin is intended for,
    >>  > but rather, in my book, a gross misuse of the concept!
    >>  
    >>  I completely agree, but it doesn't mean others won't do it. I was given
    >>  some code to debug once which was crashing 4 HOURS into elaboration. 
    >>  Who knows how long elaboration would have taken without the crash? 
    
    Nevertheless, you should consider that object design, when combined with 
    Ada "accessibility rules" imply greater importance given to elaboration.
    
    For instance, deriving a tagged type is legal only at the same level as the
    parent type. Assuming that many tagged types are (visibly or privately)
    declared in some library package, all their childs are necessarily declared
    in library packages. 
    
    Ada-95 programs will therefore make greater use (than Ada-83) of
    library elaborations. How can you design and code something like an option
    mechanism (from command line or configuration files) that must initialise
    before some type definition ?
    
    Note that I lost the initial messages, and hence cannot give any opinion on
    that particular case. I only suggest not to repeat the mistake
    ( classic about exceptions) of confusing possible misuses and absolute harm.
    I guess we, industry programmers and academic teachers, have yet to
    "elaborate" style rules about the new 95 features, among which the above
    problems.
    
    To conclude, I may envisage to agree with " this is not what elaboration is 
    intended for" but I am not sure that " what elaboration is intended for" is
    information common to everybody.
    
    ----------          ----------          ----------          ---------- 
    Michel Gauthier / Laboratoire d'informatique
    123 avenue Albert Thomas / F-87060 Limoges
    telephone +33 () 55457335 [or ~ 7232]
    fax +33 ()  55457315  [or ~7201]
    ----------          ----------          ----------          ----------
    La grande equation de la fin du siecle : windows-X = Mac-Y
    The main end-of-century equation : windows-X = Mac-Y
    ----------          ----------          ----------          ----------
    Si l'an 2000 est pour vous un mysticisme stupide, utilisez la base 9
    If you feel year 2000 a stupid mystic craze, use numeration base 9
    ----------          ----------          ----------          ----------
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
  • * Re: Elaboration order
           [not found] <314701A1.469D@lfwc.lockheed.com>
                       ` (4 preceding siblings ...)
      1996-03-19  0:00 ` Michel Gauthier
    @ 1996-03-20  0:00 ` DenReimer
      1996-03-20  0:00   ` Tucker Taft
                         ` (2 more replies)
           [not found] ` <Do8JDv.A2v@world.std.com>
      6 siblings, 3 replies; 66+ messages in thread
    From: DenReimer @ 1996-03-20  0:00 UTC (permalink / raw)
    
    
    Here's something that I'm trying to do in Ada83 and Ada95:
    
    with GENERIC_PACKAGE;
    package A_PKG is
       package INSTANCE is new GENERIC_PACKAGE ( ... );
       X : INTEGER := INSTANCE.SOME_FUNCTION;
    end A_PKG;
    
    The elaboration of X requires that the instantiated package INSTANCE be
    elaborated first (both spec and body.)  The compiler will not let me use
    pragma elaborate (INSTANCE);
    
    It is not clear to me what the elaboration order should be in the case of
    nested packages.  I would like to assume that for nested packages, the
    elaboration is also nested.  In the case of generic instantiations, both
    spec and body would be elaborated at the point of instantiation. 
    Unfortunately, the LRM does not seem to make any requirements regarding
    elaboration order for nested packages.  I've tried the above source code
    with Ada/ED and an Alsys Ada83 compiler and it seems to work OK.
    
    When I use gnat, I get a program error.  The Ada95 pragmas used for
    controlling elaboration order seem to only apply to library units.  In the
    example above, I believe that INSTANCE is a program unit but not a library
    unit.  Is there some way I can force the elaboration of INSTANCE to occur
    immediately?  The only other alternative I can think of is to create
    another compilation unit just for the instantiation so that INSTANCE will
    then be a library unit.
    
    Thanks,
    Dennis Reimer
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
  • [parent not found: <Do8JDv.A2v@world.std.com>]
  • * Elaboration Order
    @ 1999-11-15  0:00 Wolf-Dieter Heker
      1999-11-15  0:00 ` Robert Dewar
      1999-11-15  0:00 ` Jean-Pierre Rosen
      0 siblings, 2 replies; 66+ messages in thread
    From: Wolf-Dieter Heker @ 1999-11-15  0:00 UTC (permalink / raw)
    
    
    I think that Ada95 leaves too much freedom with respect to the elaborations
    order of library units unless the user specifies lots of pragmas. This was
    already the case in Ada83, although the introduction of elaborate_body
    slightly improved the situation.
    From my point of view, most of the library packages ever written are 'simple
    ones', i.e. they need no special treatment with respect to elaboration
    order.  Hence I would suggest that these packages should contain an
    elaborate_body pragma (except, of course, if the have no body). But alas,
    most programmers - including myself ;-) - do not write these pragmas until
    the get into trouble.
    The lack of these pragmas is a portability issue. And isn't it true that if
    a package body cannnot be elaborated immediately after the spec we have
    generally a doubtful design? (This is not to say there might be no reasons
    for such a structure, just that it would be more the exception rathern than
    the rule.)
    
    Now my major question: Why didn't the language designers choose an approach
    that would make the standard case easy and provide a pragma
    defer_elaboration_of_body for those rare cases, where the user doesn't want
    the body elaborated immediately after the spec? Is there more reason that
    just compatibility with the user unfriendly definition of Ada83?
    
    Wolf-Dieter Heker
    
    
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread
    [parent not found: <DoDMLL.1F9@world.std.com>]
    * Re: Elaboration order
    @ 1996-03-18  0:00 Jean-Pierre Rosen
      1996-03-21  0:00 ` Ken Garlington
      0 siblings, 1 reply; 66+ messages in thread
    From: Jean-Pierre Rosen @ 1996-03-18  0:00 UTC (permalink / raw)
    
    
    I'm surprised nobody mentionned this (or did I miss it?). If you know the
    body of the package does not have any cross-calls at elaboration (which is
    the common case), put a pragma Elaborate_Body in the spec.
    The body will then be elaborated immediately after the sepc, so no user of
    the package will run into problems with elaboration order.
    BTW: this is Ada 95 of course, but  putting the pragma in an Ada 83 program
    will not harm...
    +------------------------------------o-------------------------------------+
    | P-mail:                            | E-mail: rosen@enst.fr               |
    |   ADALOG - 27 avenue de Verdun     |    Tel: +33 1 46 45 51 12           |
    |   92170 Vanves - FRANCE            |    Fax: +33 1 46 45 52 49           |
    +------------------------------------o-------------------------------------+
    
    
    
    
    ^ permalink raw reply	[flat|nested] 66+ messages in thread

    end of thread, other threads:[~1999-11-23  0:00 UTC | newest]
    
    Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
    -- links below jump to the message on this page --
         [not found] <314701A1.469D@lfwc.lockheed.com>
         [not found] ` <1996Mar14.021345.9856@enterprise.rdd.lmsc.lockheed.com>
         [not found]   ` <314829CD.4FA9@lfwc.lockheed.com>
    1996-03-15  0:00     ` Elaboration order Tucker Taft
    1996-03-15  0:00       ` Ken Garlington
    1996-03-16  0:00     ` Ted Dennison
    1996-03-16  0:00     ` Joe Wierzbowski
    1996-03-26  0:00       ` AdaWorks
    1996-03-26  0:00         ` Robert A Duff
    1996-03-26  0:00         ` Robert Dewar
    1996-03-26  0:00           ` IO in Pure packages, debugging Laurent Guerby
    1996-03-26  0:00           ` Elaboration order Robert A Duff
    1996-03-26  0:00             ` Robert Dewar
    1996-03-26  0:00     ` Laurent Guerby
    1996-03-26  0:00       ` Robert A Duff
    1996-03-15  0:00 ` Robert I. Eachus
    1996-03-15  0:00   ` Robert Dewar
    1996-03-18  0:00 ` Ken Garlington
    1996-03-18  0:00 ` Ted Dennison
    1996-03-19  0:00 ` Michel Gauthier
    1996-03-20  0:00 ` DenReimer
    1996-03-20  0:00   ` Tucker Taft
    1996-03-20  0:00   ` Robert A Duff
    1996-03-20  0:00     ` Norman H. Cohen
    1996-03-20  0:00       ` Robert Dewar
    1996-03-20  0:00   ` Norman H. Cohen
         [not found] ` <Do8JDv.A2v@world.std.com>
         [not found]   ` <31494143.3825@lfwc.lockheed.com>
    1996-03-15  0:00     ` Mark A Biggar
    1996-03-18  0:00       ` Ken Garlington
    1996-03-19  0:00         ` Norman H. Cohen
    1996-03-20  0:00           ` Cordes MJ
    1996-03-19  0:00             ` Robert Dewar
    1996-03-21  0:00               ` Cordes MJ
    1996-03-21  0:00               ` Ken Garlington
    1996-03-20  0:00             ` Robert A Duff
    1996-03-20  0:00               ` Cordes MJ
    1996-03-20  0:00                 ` Robert Dewar
    1996-03-21  0:00                   ` Ken Garlington
    1996-03-20  0:00                 ` Robert A Duff
    1996-03-22  0:00                   ` Cordes MJ
    1996-03-23  0:00                 ` JP Thornley
    1996-03-25  0:00                   ` Robert Dewar
    1996-03-26  0:00                 ` JP Thornley
    1996-03-19  0:00         ` Chris McKnight
    1996-03-21  0:00           ` Ken Garlington
    1996-03-15  0:00     ` Robert A Duff
         [not found]       ` <EACHUS.96Mar18143219@spectre.mitre.org>
    1996-03-18  0:00         ` Robert Dewar
    1996-03-18  0:00         ` Robert Dewar
    1996-03-19  0:00           ` Ted Dennison
    1996-03-20  0:00         ` David Emery
    1996-03-18  0:00       ` Norman H. Cohen
    1996-03-20  0:00   ` Robert I. Eachus
    1996-03-22  0:00   ` Robert I. Eachus
    1996-03-22  0:00   ` Robert I. Eachus
    1999-11-15  0:00 Elaboration Order Wolf-Dieter Heker
    1999-11-15  0:00 ` Robert Dewar
    1999-11-16  0:00   ` Wolf-Dieter Heker
    1999-11-16  0:00     ` David C. Hoos, Sr.
    1999-11-16  0:00     ` Robert Dewar
    1999-11-16  0:00     ` Robert Dewar
    1999-11-20  0:00       ` Simon Wright
    1999-11-22  0:00         ` Robert Dewar
    1999-11-23  0:00           ` Mats Weber
    1999-11-15  0:00 ` Jean-Pierre Rosen
    1999-11-15  0:00   ` Robert Dewar
    1999-11-16  0:00     ` Jean-Pierre Rosen
    1999-11-20  0:00       ` Simon Wright
         [not found] <DoDMLL.1F9@world.std.com>
    1996-03-18  0:00 ` Elaboration order Chris McKnight
      -- strict thread matches above, loose matches on Subject: below --
    1996-03-18  0:00 Jean-Pierre Rosen
    1996-03-21  0:00 ` Ken Garlington
    

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