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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.118.228 with SMTP id kp4mr6033999obb.42.1406237772114; Thu, 24 Jul 2014 14:36:12 -0700 (PDT) X-Received: by 10.50.40.69 with SMTP id v5mr1531igk.6.1406237771891; Thu, 24 Jul 2014 14:36:11 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!h18no4049805igc.0!news-out.google.com!eg1ni2igc.0!nntp.google.com!h18no7006347igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 24 Jul 2014 14:36:11 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1cb91e6a-9e49-4bc8-bf4a-67a16a00e3a0@googlegroups.com> Subject: Re: Rationale for this not to compile? From: Adam Beneschan Injection-Date: Thu, 24 Jul 2014 21:36:11 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:187844 Date: 2014-07-24T14:36:11-07:00 List-Id: On Thursday, July 24, 2014 1:53:32 PM UTC-7, Victor Porton wrote: > Is there any rationale why this does not compile?=20 A generic instantiation is equivalent to "the instance declaration ... imme= diately followed by the instance body, both at the place of the instantiati= on." (12.3(12)) Since the body could contain code that depends on the repr= esentation of X already being determined, but it hasn't yet, the language m= akes this illegal. At least I think that's the rationale. AARM section 13= .14, which discusses the freezing rules, explains in more detail why types = have to be completely defined before they're used in certain cases (see htt= p://www.ada-auth.org/standards/12aarm/html/AA-13-14.html). -- Adam > If it compiled, it would=20 > be probably useful in practice with a real example similar to the below t= oy=20 > example (as to make the type T not private, I must create an *.Internal.*= =20 > package to serve as a "private repository" for types like T, as real priv= ate=20 > types cannot be used). It is called a hack. >=20 > gnatmake -q -c -gnatc -u -P/home/porton/t/default.gpr test.ads > test.ads:10:32: premature use of private type > gnatmake: "/home/porton/t/test.ads" compilation error >=20 > package Test is >=20 > generic > type T is limited private; > package Gen is > end Gen; >=20 > type X is private; >=20 > package Instance is new Gen(X); >=20 > private > type X is null record; > end Test;