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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f9c25380ec58962 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.211.195 with SMTP id ne3mr5651152pbc.2.1326646640791; Sun, 15 Jan 2012 08:57:20 -0800 (PST) Path: lh20ni185500pbb.0!nntp.google.com!news1.google.com!postnews.google.com!m4g2000vbc.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Elaboration circularity with generics Date: Sun, 15 Jan 2012 08:55:57 -0800 (PST) Organization: http://groups.google.com Message-ID: <3a04e681-8180-4722-9b19-414173073d8e@m4g2000vbc.googlegroups.com> References: <583b1bfe-95bd-4669-b16b-c733c81e8f88@w4g2000vbc.googlegroups.com> NNTP-Posting-Host: 91.7.67.241 Mime-Version: 1.0 X-Trace: posting.google.com 1326646640 12763 127.0.0.1 (15 Jan 2012 16:57:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 15 Jan 2012 16:57:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m4g2000vbc.googlegroups.com; posting-host=91.7.67.241; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.0; rv:8.0.1) Gecko/20100101 Firefox/8.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-01-15T08:55:57-08:00 List-Id: On 14 Jan., 23:46, Simon Wright wrote: > AdaMagica writes: > > A unit can only be instantiated if it is fully elaborated. > > I guess GNAT chose the elaboration order P'Spec, P.Q'Spec, P'Body > > (crash since P.Q'body is not elaborated). > > This dependence is not present for nongeneric units. > > > Perhaps addition of pragma Elaborate_Body to P.Q helps. > > =A0 =A0with P.Q; > =A0 =A0pragma Elaborate (P.Q); =A0 =A0 =A0 =A0 =A0<<<<<<< does the trick = for me > =A0 =A0package body P is Of course this works, but in my opinion, Elaborate_Body is better because it has to be applied just once to P.Q, whereas Elaborate has to be applied on every unit withing P.Q. As a general rule of thumb I think Elaborate_Body should be applied whenever a unit provides functions that are used in the spec of other units providing initial values or constants, such like: package P is pragma Elaborate_Body; -- prevents elaboration error when F is called function F (...) return T; end P; with P; -- no need for "pragma Elaborate (P);" package Q is V: [constant] T :=3D P.F (...); end Q;