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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Ada Successor Language Date: Sun, 24 Jun 2018 10:19:32 +0100 Organization: Adalog 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> NNTP-Posting-Host: wZ92b1Jf6WKcedzDuqoRAA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Openpgp: preference=signencrypt X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: fr Xref: reader02.eternal-september.org comp.lang.ada:53277 Date: 2018-06-24T10:19:32+01:00 List-Id: Le 24/06/2018 à 09:34, Dmitry A. Kazakov a écrit : > That is not possible because generic formal contracts are weakly typed. > Consider, for simplicity, this: > >    with Ada.Finalization; >    generic >       type T is new Ada.Finalization.Controlled with private; >    package P is >       type S is new T with null record; >       not overriding procedure Foo (X : S); >    end P; > > If the given descendant of Controlled has Foo already, you are out of > luck. The contract says: any descendant of Ada.Finalization.Controlled. > That is a lie. You really need to understand the rules: "assume the best" in generic specifications, "assume the worse" in generic bodies. i.e. a generic spec is legal if there is at least one legal instantiation. This is because the user is assumed to see the specification, and therefore understand why some instantiation is rejected. a generic body is illegal if there is at least one illegal instantiation. This is because the user is not assumed to see the body of a generic. Hint: a generic can be made legal by moving some declarations from the body to the specification (even into the private part). -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr