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: 103376,ea5071f634c2ea8b X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.59.229 with SMTP id c5mr16297347pbr.6.1321883423414; Mon, 21 Nov 2011 05:50:23 -0800 (PST) Path: lh20ni1665pbb.0!nntp.google.com!news1.google.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Generic-Package Elaboration Question / Possible GNAT Bug. Date: Mon, 21 Nov 2011 14:50:12 +0100 Organization: cbb software GmbH Message-ID: <128rdz2581345$.c4td19l7qp9z$.dlg@40tude.net> References: <7bf9bc32-850a-40c6-9ae2-5254fe220533@f29g2000yqa.googlegroups.com> <4295dc09-43de-4557-a095-fc108359f27f@y42g2000yqh.googlegroups.com> <3snehoqgs8ia$.1nobjem6g6hx6$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.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 Xref: news1.google.com comp.lang.ada:18991 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-11-21T14:50:12+01:00 List-Id: On Mon, 21 Nov 2011 08:08:04 -0500, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >>>> I don't know if Ada keeps that promise for generic bodies, ... > > I think it does. I'd be interested in any counterexamples. GNAT sometimes reports errors in generic bodies upon instantiation, but I am not sure if these are not compiler bugs. >>...Generic contracts are too weak for that. > > Well, it's not that the contracts are too weak. You just have to > consider the entire generic spec (including the private part, > unfortunately), as part of the "contract". That is C++'s approach. If matching formal parameters does not imply legality, that does not look very contracted. > Also, the generic contract model applies only to compile-time rules. Sure, that is a contract model of the meta language of generics. If it were properly contracted generics produced only legal "Ada proper" programs. > The fact that the instance body is guaranteed to be legal doesn't > mean that it will work properly! Yes, the same applies to non-generic subprograms. Properly typed arguments do not guaranty it working. Legality does not imply correctness. > And there are a few cases where we > deliberately "cheat" in the RM, by making something raise an exception > in a generic, when it would normally be a legality rule. Conversion of errors into exceptions is an extremely bad idea. The same fault is represented by dynamic pre-/pos-conditions, assertions, accessibility checks, tag errors. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de