comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Strange error message
Date: Mon, 2 Jun 2014 09:47:56 +0200
Date: 2014-06-02T09:47:56+02:00	[thread overview]
Message-ID: <17l7hex6vxkj4.wul0z12r7f85.dlg@40tude.net> (raw)
In-Reply-To: wcctx84qqgk.fsf@shell01.TheWorld.com

On Sun, 01 Jun 2014 17:18:03 -0400, Robert A Duff wrote:

> Charly <carl.weierstrass@googlemail.com> writes:
> 
>> when I defined a class hierarchy I encountered a problem, that I could reduce 
>> to the following few lines:
>>
>> This version compiles without problems:
>> -----------------
>> package Test is
>>
>>    type Base is tagged private;
>>    function Create return Base;
>>
>>    type High is new Base with private;
>>
>> private
>>
>>    type Base is tagged null record;
>>
>>    type High is new Base with null record;
>>
>> end Test;

> I don't know why Dmitry and Randy want us to write that out explicitly;
> it seems like an obviously useful and safe default.

The first objection is that the legality of inheriting Create in

   type Base is tagged private;
   function Create return Base;

   type High is new Base with private;
 
depends on the private part of the package. This is not good.

The second objection is, if the above is not good then

   type High is new Base with null record;

should make no difference.

---------------
Of course one could argue in favor of the rule that all primitive
operations are in some sense overridden anyway. It is only the way the
bodies are constructed (inherited vs. provided by the user), what makes
difference. I.e. whether

   overriding function Create return High;

appears in the public part of the package or not, that is an implementation
detail uninteresting to the clients. I would agree with that, but it is not
how the language is designed presently.

It is, as always, too late, but probably overriding (with new body) were to
appear strictly in the package body. Then the rule of null extension would
be all OK to me.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2014-06-02  7:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-01 10:24 Strange error message Charly
2014-06-01 11:11 ` Dmitry A. Kazakov
2014-06-01 12:50   ` Charly
2014-06-01 13:54     ` Simon Wright
2014-06-01 21:18 ` Robert A Duff
2014-06-02  7:47   ` Dmitry A. Kazakov [this message]
2014-06-02 13:49     ` Robert A Duff
2014-06-02 14:55       ` Dmitry A. Kazakov
2014-06-02 17:24         ` Robert A Duff
2014-06-02 18:39       ` Shark8
2014-06-02 19:56   ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2002-11-13 10:36 strange " evangeli
2002-11-13 15:05 ` Stephen Leake
replies disabled

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