comp.lang.ada
 help / color / mirror / Atom feed
From: dog.ee.lbl.gov!agate!howland.reston.ans.net!noc.near.net!nic.umass.edu!ym ir.cs.umass.edu!rcfnews!sandy@ucbvax.Berkeley.EDU  (Sandy Wise)
Subject: Re: Odd Generic Behaviour <<LRM Experts Whats Going ON??
Date: 26 Aug 93 23:07:18 GMT	[thread overview]
Message-ID: <SANDY.93Aug26160718@beeker.cs.umass.edu> (raw)

BERRYMAN@orca.drep.dnd.ca (DON BERRYMAN) writes:
   I have discovered an odd behavour of ADA when I attempt to specify and use
   a generic package inside a package specification (Pack1, code and audit of
   compilation follow).  Not being an LRM expert this looked like a reasonable
   package specification, and both the Alsys/Hp & Dec/Vax compilers accepted
   it with out a single error.  So I assume that the code will work (except for
   my stupid logic errors).

   With Alsys/Hp the code links fine but blows up with a PROGRAM_ERROR before
   executing a single line of code.  None of the TEXT_IO.PUT_LINES gets
   executed.  All I get is a trace pointing into PACK1.

Welcome the mysterious world of elaboration order...

LRM 11.1 indicates that "PROGRAM_ERROR is raised upon an attempt [...]
to elaborate a generic instatiation, if the body of the corresponding
unit has not yet been elaborated."

LRM 10.5 requires that a spec be elaborated before any entity that
with's it and that a spec be elaborated before its body.  But does not
place any requirements on the elaboration order of bodies except that
they must be elaborated before the program starts.

So.  The problem here is that you are violating LRM 11.1 since the
body of GEN1 is not elaborated at the time of instantiation.

Moreover, the body of GEN1 is nested inside PACK1 and cannot have been
elaborated yet since that would require the elaboration of the body of
PACK1 before the elaboration of GEN1 (forbidden by 10.5).

Move GEN1 outside of PACK1.  The header to PACK1 becomes:

with GEN1;
pragma ELABORATE (GEN1); -- ensure the body of GEN1 is elaborated
                         -- before use...
package PACK1 is ...

        /s
--
Alexander Erskine Wise /\/\/\/\/\/\/\/\/\/\/\/\ Software Development Laboratory
/\/\/\/\/\/\/\/\/\/\/\/\/\/\ WISE@CS.UMASS.EDU /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\ This situation calls for large amounts of unadulterated CHOCOLATE! /\/\/\

             reply	other threads:[~1993-08-26 23:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-26 23:07 dog.ee.lbl.gov!agate!howland.reston.ans.net!noc.near.net!nic.umass.edu!ym [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-08-27 18:01 Odd Generic Behaviour <<LRM Experts Whats Going ON?? cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.ed
1993-08-26 19:27 agate!howland.reston.ans.net!math.ohio-state.edu!uwm.edu!linac!convex!con
1993-08-26 17:33 DON BERRYMAN
replies disabled

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