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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,556e5b18154df788 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.180.10.230 with SMTP id l6mr3496231wib.3.1364940230782; Tue, 02 Apr 2013 15:03:50 -0700 (PDT) Path: ex12ni19365wid.1!nntp.google.com!feeder1.cambriumusenet.nl!82.197.223.103.MISMATCH!feeder3.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.86.MISMATCH!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newspeer1.nac.net!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.bbs-scene.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Interresting, possibly buggy behavior in GNAT generics w/ expression function. Date: Sat, 30 Mar 2013 10:24:05 +0100 Organization: cbb software GmbH Message-ID: <1ilubaaaex6jp$.zd9lslst85nn.dlg@40tude.net> References: <1k6ipbtagwzw4$.1dv47rfygcedg.dlg@40tude.net> <1ex3dm2hk2j54$.1uiyljwziv0hi$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: XRUMb5xlbonTNodERpEXEw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2013-03-30T10:24:05+01:00 List-Id: On Fri, 29 Mar 2013 19:56:05 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1ex3dm2hk2j54$.1uiyljwziv0hi$.dlg@40tude.net... > ... >>> But, do you think it should have failed at instantiation? >> >> It should fail to compile, instantiation time is too late. Generic >> contracts are much too weak. > > This doesn't make much sense, as you then go on to suggest adding a formal > contract which would have the effect of rejecting an instantiation if the > type actually had Foo. That's exactly what Ada does, so I don't see any > advantage of a complication. That is because you consider only one possibility, that is a client-side error. Then instantiation is the right time to report this contract violation. For the generic package itself this time is when the generic is compiled. My example had the purpose to show that matching formal parameters is not enough. It could illustrate an error in the generic itself as well, e.g. when *all* intended actual types for instantiations of P have Foo per design. > The problem you are having is that you are viewing the contract of a generic > in too narrow of a fashion. The contract includes not only the things in the > generic part, but also a number of properties expressed in the rest of the > specification. You lumped together two different contracts. There is a contract on the actual parameters which is defined by be the formal parameters specification. Another contract is the generic package specification (public part), which is a contract for the clients using an instance of the package. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de