comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Constructing an object
Date: Sat, 1 Oct 2005 12:49:27 +0200
Date: 2005-10-01T12:49:13+02:00	[thread overview]
Message-ID: <1h1ooovh0igvo.1ea57ledo3rrc.dlg@40tude.net> (raw)
In-Reply-To: GaWdncMchraYRqDeRVn-1Q@megapath.net

On Fri, 30 Sep 2005 19:44:22 -0500, Randy Brukardt wrote:

> Actually, it wouldn't be that hard to add that to Ada 200Y. We have the
> "overriding" keyword to specify overriding. Additional keywords could
> specify other types of extension -- "extends" perhaps. That would look like:
> 
>     extends
>     procedure Finalize (Obj : in out My_Type);
> 
> or perhaps
> 
>     extends after
>     procedure Finalize (Obj : in out My_Type);
> 
> to specify when the parent routine is called.

Here is an alternative schema, which is actually a frequently used pattern. 
One could automate it: let each class-wide subroutine F have 
language-defined primitive operations F'Prologue and F'Epilogue. So:

   type T is tagged ...;
   type Foo (Obj : in out T'Class); -- An extensible operation on the class

   type My_Type is new T with ...;
   overriding procedure Foo'Prologue (Obj : in out My_Type); 
   overriding procedure Foo'Epilogue (Obj : in out My_Type); 

(of course F'{Pro|Epi}logue cannot be called directly)

But there is also safety issue. At least in constructors and destructors 
the parent should be able to prevent overriding of either the prologue or 
epilogue.

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



  reply	other threads:[~2005-10-01 10:49 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-21  8:46 Constructing an object Maciej Sobczak
2005-09-21 10:16 ` Georg Bauhaus
2005-09-22  7:21   ` Maciej Sobczak
2005-09-21 11:55 ` Dmitry A. Kazakov
2005-09-22  7:28   ` Maciej Sobczak
2005-09-22  7:45     ` Maciej Sobczak
2005-09-22 13:33       ` Dmitry A. Kazakov
2005-09-24  5:23         ` Randy Brukardt
2005-09-24  9:47           ` Dmitry A. Kazakov
2005-09-29  0:12             ` Randy Brukardt
2005-09-29  8:17               ` Dmitry A. Kazakov
2005-09-29 22:21                 ` Randy Brukardt
2005-09-30  8:14                   ` Jean-Pierre Rosen
2005-09-30 19:28                     ` Dmitry A. Kazakov
2005-09-30 17:49                   ` Robert A Duff
2005-10-01  0:44                     ` Randy Brukardt
2005-10-01 10:49                       ` Dmitry A. Kazakov [this message]
2005-10-01 11:06                       ` Tapio Kelloniemi
2005-10-01 14:13                         ` Robert A Duff
2005-10-02 11:52                           ` Tapio Kelloniemi
2005-10-01 15:19                       ` Georg Bauhaus
2005-09-23  5:40 ` Matthew Heaney
2005-09-23  7:18   ` tmoran
2005-09-23  8:23   ` Maciej Sobczak
2005-09-23 12:04     ` Dmitry A. Kazakov
2005-09-23 12:36       ` Matthew Heaney
2005-09-23 13:03         ` Hyman Rosen
2005-09-23 13:41           ` Maciej Sobczak
2005-09-23 14:23           ` Matthew Heaney
2006-01-17  6:28             ` [Offtopic] " James Dennett
2005-09-23 13:42         ` Dmitry A. Kazakov
2005-09-23 14:27           ` Matthew Heaney
2005-09-23 12:24     ` Matthew Heaney
2005-09-24  5:34       ` 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