From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Array slices and types
Date: Thu, 21 Aug 2008 10:53:50 +0200
Date: 2008-08-21T10:53:52+02:00 [thread overview]
Message-ID: <mxlm26noiy7f$.r22nktgl3jiv.dlg@40tude.net> (raw)
In-Reply-To: 48acfbe8$0$23588$4f793bc4@news.tdc.fi
On Thu, 21 Aug 2008 08:26:26 +0300, Niklas Holsti wrote:
> But doesn't this example show that it would be useful to have 'Base
> also for array types?
For any type, actually.
Consider this language design fault:
procedure Initialize (X : in out S) is
begin
Initialize (T (X));
... -- My stuff
end Initialize;
A call to Initialize should be done automatically, but it is not. So the
parent of S must be explicitly specified and known to all descendant. This
is a really *bad* thing:
package Foo is
type S is new T with private;
private
type S is new Private_Decendant_Of_T with ...;
end Foo;
What would happen if Private_Decendant_Of_T overrode Initialize of T? The
result would be an inability to publicly derive from S any new types if
Initialize should be extended!
S'Base could mend it:
procedure Initialize (X : in out S) is
begin
(S"Base (X)).Initialize; -- Call to parent whatever it be
... -- My stuff
end Initialize;
Presently the only way is to override Initialize, Finalize and Adjust
everywhere, even if you actually don't want to extend them:
package Foo is
type S is new T with private;
overriding procedure Initialize (X : in out S); -- Have to do this!
private
type S is new Private_Decendant_Of_T with ...;
end Foo;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-08-21 8:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 14:51 Array slices and types Maciej Sobczak
2008-08-20 15:26 ` Niklas Holsti
2008-08-20 15:46 ` Dmitry A. Kazakov
2008-08-20 18:52 ` Niklas Holsti
2008-08-20 20:01 ` Simon Wright
2008-08-21 5:26 ` Niklas Holsti
2008-08-21 8:53 ` Dmitry A. Kazakov [this message]
2008-08-21 14:44 ` Adam Beneschan
2008-08-21 15:46 ` Dmitry A. Kazakov
2008-08-22 4:30 ` Randy Brukardt
2008-08-20 17:47 ` stefan-lucks
2008-08-20 17:51 ` stefan-lucks
2008-08-20 20:45 ` Adam Beneschan
2008-08-21 21:16 ` Maciej Sobczak
2008-08-23 2:50 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox