From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: overriding in private part
Date: Mon, 6 Oct 2008 10:50:04 +0200
Date: 2008-10-06T10:50:04+02:00 [thread overview]
Message-ID: <16aosnc43o0l2.1snh410eman0v$.dlg@40tude.net> (raw)
In-Reply-To: wcck5cm24sj.fsf@shell01.TheWorld.com
On Sun, 05 Oct 2008 15:57:48 -0400, Robert A Duff wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> On Sat, 04 Oct 2008 15:47:04 -0400, Robert A Duff wrote:
>>
>>> If you use a compiler that warns on missing "overriding", then you don't
>>> need to say "not overriding", because that's the default -- any
>>> subprogram that doesn't say "overriding" is not overriding.
>>> Saying "not overriding" is just noise.
>>
>> [...]
>>
>>> I agree that if you want an indicator on every subprogram declaration,
>>> then forbidding "no overriding" on some non-overriding subprograms is a
>>> language design mistake. But I don't want that -- I want a safe
>>> (non-overriding) default.
>>
>> But non-overriding is unsafe. Taking your example with in and in-out, when
>> the programmer uses in instead of in-out, that does not change the program
>> semantics, so long the program remains legal. Otherwise (if the body
>> actually changes the parameter) it will not compile. This is safe.
>
> Good point, but I'm only half convinced. If you get in the habit of
> always saying "overriding" when appropriate, and you use the warnings,
> then you're unlikely to get into trouble. And the idea of putting "not
> overriding" all over the place seems awfully verbose, to me.
Both are unsafe. A felt verbosity comes from the strange decision to put
[not] overriding in front of the declaration. If it were:
procedure Foo (X : Boo) is not overriding;
it would not be so offending.
As for me, I think that overriding could be a good default for all
subprograms with at least one controlling argument. Declarations of any new
primitive operation should then be explicit:
procedure Foo (X : Boo) is [abstract] new; -- I hate "overriding"
Non-primitive operations should be made illegal if any of the arguments is
controlling:
type T is tagged ...;
procedure Foo (X : T) is new;
package Bar is
procedure Foo (X : T); -- You cannot do this!
procedure Baz (X : T); -- Neither this!
procedure Baz (X : T'Class); -- This is OK
end Bar;
Maybe, that could be relaxed the bodies of the packages which
specifications declare the type:
package A is
type X is tagged ...;
end A;
package body A is
procedure Some_Private_Stuff_Without_Redispatch (X : T) is not new;
end A;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-10-06 8:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-02 15:49 overriding in private part Maxim Reznik
2008-10-02 16:42 ` Adam Beneschan
2008-10-03 8:52 ` Dmitry A. Kazakov
2008-10-03 15:54 ` Adam Beneschan
2008-10-03 20:29 ` Robert A Duff
2008-10-04 2:28 ` Randy Brukardt
2008-10-04 19:47 ` Robert A Duff
2008-10-05 7:35 ` Dmitry A. Kazakov
2008-10-05 19:57 ` Robert A Duff
2008-10-06 8:50 ` Dmitry A. Kazakov [this message]
2008-10-06 23:32 ` Randy Brukardt
2008-10-05 11:46 ` stefan-lucks
2008-10-05 20:08 ` Robert A Duff
2008-10-06 23:39 ` Randy Brukardt
2008-10-02 23:17 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox