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,16e3a8dd4f3ab3f3 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Elaboration order Date: 1996/03/20 Message-ID: #1/1 X-Deja-AN: 143387765 references: <314701A1.469D@lfwc.lockheed.com> <4io8rn$gfn@newsbf02.news.aol.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-03-20T00:00:00+00:00 List-Id: In article <4io8rn$gfn@newsbf02.news.aol.com>, DenReimer wrote: >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; You need pragma Elaborate[_All](Generic_Package), assuming the generic itself doesn't have any pragma (like Elaborate_Body). This has nothing to do with your call -- there is a run-time check on *instantiation*. Having done that, your call is fine. There's never any need for these pragmas in the nested case (in fact, they're illegal), since nested things are elaborated right where they appear in the code. And the spec and body of an instance are elaborated at the point of the instantiation. So, if you get elaboration order problems in the nested case, you don't use pragmas -- you just rearrange the code into a correct order. >... 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. That's the non-portability I was grumbling about in a previous post. Don't blame gnat for this -- it just happened to choose a different order than the other compilers. - Bob