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=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,158ce2376534c35d X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!news.albasani.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Derived private interface Date: Wed, 6 Jul 2011 14:20:38 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <27656578-65aa-48b9-9f89-4ebd4e0cb02a@glegroupsg2000goo.googlegroups.com> <0fe3b0f8-c064-444d-899d-640e891b58c3@w4g2000yqm.googlegroups.com> <128d8eb5-1cc6-47e3-a09b-b53a5ef289ce@m10g2000yqd.googlegroups.com> <4e141501$0$6629$9b4e6d93@newsspool2.arcor-online.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1309980042 24765 69.95.181.76 (6 Jul 2011 19:20:42 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 6 Jul 2011 19:20:42 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 Xref: g2news1.google.com comp.lang.ada:20101 Date: 2011-07-06T14:20:38-05:00 List-Id: "Georg Bauhaus" wrote in message news:4e141501$0$6629$9b4e6d93@newsspool2.arcor-online.net... > On 7/6/11 6:34 AM, AdaMagica wrote: >> I should have written >> >> overriding procedure Doit (X: access Derived_Class); > > Instead of sprinkling the program with overriding indicators, > shouldn't it be normal for a compiler to detect the status of > a subprogram WRT overriding? Sure, but what the compiler decides and what the programmer expects are very often different. The intent of indicators is to tell the compiler what the programmer is expecting. > (It is, I think, and not just in > Ada.) Consequently, programmers would mark the opposite case. > They'd write "not overriding" only if a subprogram is really > intended to not be overriding. That would work if the compiler rejected routines that were not overriding unless "not overriding" appears. But Ada doesn't work that way (because it inherited a bad model from Ada 95). Routines that didn't override when they were expected to cost us more than 100 hours of debugging when we building Claw. Typos, changes to the root classes, and interactions with Ada's visibility rules all caused routines to not override when they should have. Overriding indicators were invented specifically to address this problem; the original intent was to include a state where it was illegal to override unless the indicator was provided. (Semantic issues with that caused it to be abandoned.) "Not overriding" is far less important. > Premises: > - A subprogram is an overriding subprogram in most cases. > + I.e., a subprogram following a type declaration is usually > intended to override. Here, "usually" refers to OOD > being ubiquitous. That is only true for derived types (including type extensions); it's never true for any other kind of type. > - Idiomatic use will suggest to place non-overriding subprograms > in nested packages (factories, for example). That makes no sense, as any time an extension adds new operations you will want those to be primitive and inherited in further extensions. Claw has a lot of such operations. > - Compilers will warn in any case whenever they detect > a subprogram that looks suspicious. That's not possible in any reasonable way. It's quite common to add overrloaded operations with additional/different parameters in an extension. As a result, Janus/Ada has no such warnings, because we couldn't find anything that wouldn't be "crying wolf" more often than it would be telling something useful. And proper use of indicators is better anyway, because the program is rejected if wrong. Randy.