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.200.45.26 with SMTP id n26mr19418110qta.27.1499102665525; Mon, 03 Jul 2017 10:24:25 -0700 (PDT) X-Received: by 10.36.3.81 with SMTP id e78mr496324ite.9.1499102665475; Mon, 03 Jul 2017 10:24:25 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!m54no2140631qtb.1!news-out.google.com!s132ni1669itb.0!nntp.google.com!188no919475itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 3 Jul 2017 10:24:25 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.201.205; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.201.205 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: derived formal types and known discriminants From: Jere Injection-Date: Mon, 03 Jul 2017 17:24:25 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47267 Date: 2017-07-03T10:24:25-07:00 List-Id: On Thursday, June 22, 2017 at 8:45:22 PM UTC-4, sbelm...@gmail.com wrote: > Can any language lawyer explain the reasoning behind precluding known dis= criminants for general formal derived types? For example, I can write this= : >=20 > generic > type T is new P with private; -- constrained (i.e. none) > =20 > and I can write this: >=20 > generic > type T (<>) is new P with private; -- unconstrained (i.e. any) > =20 > But I can't write >=20 > generic > type T (foo : Integer) is new P with private; -- (just one integer) > =20 > presumably because 12.5.1~11/3 says "The declaration of a formal derived = type shall not have a known_discriminant_part", to wit GNAT complains "disc= riminants not allowed for this formal type". It would seems as though if u= nknown discriminants are legal, known would be an easier subset, and my int= erest has been piqued to the reason why. >=20 > Thank you for any insight >=20 > -sb I've often wondered this myself. The best I came up with was to use an int= ermediate type: type NP(Foo : Integer) is new P with null record; and then do the generic like this: generic type T is new NP with private; package G is subtype Test_Type is T; end G; A bit more cumbersome, but that's how I managed it.