comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Derived private interface
Date: Wed, 6 Jul 2011 14:20:38 -0500
Date: 2011-07-06T14:20:38-05:00	[thread overview]
Message-ID: <iv2ci9$o5t$1@munin.nbi.dk> (raw)
In-Reply-To: 4e141501$0$6629$9b4e6d93@newsspool2.arcor-online.net

"Georg Bauhaus" <rm.dash-bauhaus@futureapps.de> 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.





      parent reply	other threads:[~2011-07-06 19:20 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  3:14 Derived private interface Rego, P.
2011-07-05  5:10 ` AdaMagica
2011-07-06  2:24   ` Rego, P.
2011-07-06  4:34   ` AdaMagica
2011-07-06  7:55     ` Georg Bauhaus
2011-07-06  8:30       ` AdaMagica
2011-07-06 12:59         ` Georg Bauhaus
2011-07-06 13:23           ` AdaMagica
2011-07-06 19:06             ` Randy Brukardt
2011-07-06 13:28           ` Simon Wright
2011-07-06 19:45           ` Randy Brukardt
2011-07-06 22:05             ` Georg Bauhaus
2011-07-06 23:56               ` Adam Beneschan
2011-07-07 14:09                 ` Georg Bauhaus
2011-07-07 15:10                   ` Adam Beneschan
2011-07-08  4:29                     ` AdaMagica
2011-07-08 19:08                       ` Randy Brukardt
2011-07-08 19:12                     ` Randy Brukardt
2011-07-07 15:19                   ` Georg Bauhaus
2011-07-07 10:37         ` Stephen Leake
2011-07-07 13:18           ` Georg Bauhaus
2011-07-08 19:23             ` Randy Brukardt
2011-07-08 21:41               ` Jeffrey Carter
2011-07-09  6:14                 ` Dmitry A. Kazakov
2011-07-22 22:59                 ` Randy Brukardt
2011-07-23  7:30                   ` Jeffrey Carter
2011-07-23  9:29                     ` Maciej Sobczak
2011-07-23 10:07                     ` Dmitry A. Kazakov
2011-07-26 21:04                     ` Randy Brukardt
2011-07-26 23:43                       ` Jeffrey Carter
2011-07-27 23:56                         ` Randy Brukardt
2011-07-28  0:18                           ` Jeffrey Carter
2011-07-28 10:06                         ` Maciej Sobczak
2011-07-28 23:24                           ` Randy Brukardt
2011-07-29  6:45                             ` Simon Wright
2011-07-30  0:04                               ` Randy Brukardt
2011-07-30  6:32                                 ` Simon Wright
2011-08-01  9:30                                   ` Alex R. Mosteo
2011-08-01 10:12                                     ` Dmitry A. Kazakov
2011-08-01 21:56                                       ` Randy Brukardt
2011-08-02 10:03                                         ` Dmitry A. Kazakov
2011-08-02 21:16                                           ` Randy Brukardt
2011-08-03  9:01                                             ` Dmitry A. Kazakov
2011-08-03 20:16                                               ` Randy Brukardt
2011-08-04  8:15                                                 ` Dmitry A. Kazakov
2011-08-09 21:10                             ` Maciej Sobczak
2011-08-09 21:35                               ` Randy Brukardt
2011-08-10  9:11                                 ` Dmitry A. Kazakov
2011-08-10 21:56                                   ` Randy Brukardt
2011-08-11  8:07                                     ` Dmitry A. Kazakov
2011-08-12  4:52                                       ` Randy Brukardt
2011-08-12  8:54                                         ` Dmitry A. Kazakov
2011-08-10 10:07                                 ` Maciej Sobczak
2011-08-10 11:26                                   ` Georg Bauhaus
2011-08-10 22:27                                     ` Randy Brukardt
2011-08-10 22:21                                   ` Randy Brukardt
2011-08-11 13:50                                     ` Maciej Sobczak
2011-08-12  4:43                                       ` Randy Brukardt
2011-08-12  7:00                                         ` Maciej Sobczak
2011-08-12 21:59                                           ` Randy Brukardt
2011-07-06 15:06       ` Adam Beneschan
2011-07-06 16:36       ` Dmitry A. Kazakov
2011-07-06 19:20       ` Randy Brukardt [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox