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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,547e6c7b9fae4e1d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-23 06:21:04 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!nntp-relay.ihug.net!ihug.co.nz!news.compaq.com!paloalto-snf1.gtei.net!denver-snf1.gtei.net!news.gtei.net!coop.net!world!news From: Robert A Duff Subject: Re: Instanciation in a package spec. User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Thu, 23 Jan 2003 14:19:49 GMT Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-1 References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:33373 Date: 2003-01-23T14:19:49+00:00 List-Id: "Jean-Pierre Rosen" writes: > "Robert A Duff" a �crit dans le message de news: wccel752ki5.fsf@shell01.TheWorld.com... > > "Grein, Christoph" writes: > > > > > > * GNAT 3.15p issues: > > > > pascalhe.ads:135:03: warning: cannot instantiate "Ad_hoc" before body seen > > > > pascalhe.ads:135:03: warning: Program_Error will be raised at run time > > > > > > Believe Gnat. It's a RM rule to forbid instantiations before elaboration of the body. > > > > A very annoying rule, indeed. > > > ???? > Since the body of the instance is elaborated at the point of instanciation, the body of the > generic has better been elaborated already.... I understand the *need* for the rule in Ada. But it's still an annoying restriction. It's perfectly reasonable to want to export a generic and an instance of that generic from the same package. But Ada's elaboration model prevents it. It's also annoying that you can't call a function in the same package: package P is function F(...) return T; X: constant T; private X: constant T := F(...); -- raises P_E. end P; The problem here is the elaboration model of Ada. The *visibility* of things is too closely tied to the *elaboration* order. I have worked out a different model of elaboration that doesn't have this problem (but still retains all the advantages of the Ada model). Unfortunately, it's not Ada. The end result of these restrictions is that you have to introduce all kinds of extra packages and other declarations that are irrelevant to the conceptual design. And you pollute the clients with that bogus structure. I run into this problem fairly often, and I find it really damages the structure of the software. - Bob