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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Ada Successor Language Date: Mon, 25 Jun 2018 16:18:47 +0200 Organization: A noiseless patient Spider Message-ID: References: <5e86db65-84b9-4b5b-9aea-427a658b5ae7@googlegroups.com> <878t7u1cfm.fsf@nightsong.com> <776f3645-ed0c-4118-9b4d-21660e3bba4b@googlegroups.com> <87602fbu2g.fsf@nightsong.com> <87po0mziqt.fsf@nightsong.com> <87fu1izfgs.fsf@nightsong.com> <878t75nwad.fsf@adaheads.home> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 25 Jun 2018 14:18:48 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="56798da69b8456a859013d3840662c32"; logging-data="11252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LGEk7ai7ZBuePJHy5MPS5" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:R2sINHcgsyKHbD7GkjvOemrOvjo= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:53300 Date: 2018-06-25T16:18:47+02:00 List-Id: On 25/06/2018 14:41, J-P. Rosen wrote: > Le 25/06/2018 à 10:58, Alejandro R. Mosteo a écrit : >> See this one, which is the case that bit me recently: >> >> procedure Blah is >>     generic >>         type Something is private; >>     package Duh is >>         type Meh is new Something; >>     end Duh; >> >>     type Oh is tagged null record; >> >>     package Ouch is new Duh (Oh); >> >> begin >>    null; >> end Blah; > > A private formal allows tagged and untagged types. However, deriving > without extension is legal only for untagged types. Since it is a > specification (that you are supposed to have read), the compiler assumes > the best and allows the derivation. When you instantiate with a tagged > type, you would be doing something illegal and the instantiation is not > allowed. Someone explained it to me at the time, and your best/worst explanation is great. It was rather an example of that you can have a generic that compiles, a type that fulfills the generic formal, and an instantiation that fails, which admittedly irks me. > The same derivation would not compile in the body of the generic, where > the worst is assumed GNAT 7.3/2018 does compile it if I move it to the private part or body, which thus must be a bug, as hinted by that it allows taking the type's 'Class... procedure Blah is generic type Something is private; package Duh is private type Meh is new Something; function Yes (M : Meh) return Boolean is (True); function Yes_Class (M : Meh'Class) return Boolean is (True); end Duh; type Oh is tagged null record; package Ouch is new Duh (Oh); -- This fails with non-tagged formal begin null; end Blah;