comp.lang.ada
 help / color / mirror / Atom feed
From: Tapio Kelloniemi <invalid@localhost.localdomain.com>
Subject: Re: Constructing an object
Date: Sat, 01 Oct 2005 11:06:36 GMT
Date: 2005-10-01T11:06:36+00:00	[thread overview]
Message-ID: <05u%e.31514$176.27928@reader1.news.jippii.net> (raw)
In-Reply-To: GaWdncMchraYRqDeRVn-1Q@megapath.net

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2762 bytes --]

"Randy Brukardt" <randy@rrsoftware.com> wrote:
>"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message
>news:wccirwi30q7.fsf@shell01.TheWorld.com...
>...
>> The Common Lisp Object System has such a feature.  You can declare
>> methods that are called in addition to the parent's version (either
>> before or after) rather than the more common feature of calling them
>> instead of the parent's version.  And I think there's a feature for
>> declaring a method that must call the parent's version somewhere within
>> it -- or something like that.
>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.

Or perhaps:
   extending
   procedure ...;
or:
   procedure ... is extending;

These would be more English-like and would be coherent with overriding.

>But I think that we'd only want to support calling the parent routine first
>or last; special syntax for calling it in the middle hardly seems worth it
>(and getting the parameters right then would be messy - calling the parent
>last could be done with jumps, and first probably also could be done with
>shared code).

Dylan solves this with a special method called next-method. This
calls the next appropriate method with the same parameters as current
method was caled, unless the caller provides new p�rameters to be used
instead. This also works in multiple inheritance environment. This could
be adopted into Ada in a form of a special statement
like: parent Method (Self, parameters);
Or like: Method (Self'Parent_View, parameters);
This form of call can be put anywhere in a function or procedure body and
the programmer may use different parameters in calling Parent than what
where given to it. This is very useful, since an overridden implementation
may accept values which are being rejected by its parent method. Compilers,
however, need to do some extra work in this approach since they should
try their best to detect, if the parent is not called. If this fails
and the parent method is not called at run time, Program_Error would
be raised. I don't think this is a big problem since in most cases missing
parent method call can be identified like missing return statement.

>I'm mildly sorry I didn't think of this when we were working on "overrides";
>its a rather natural extension to the idea that also helps to prevent bugs.

Perhaps in Ada2015 then, or perhaps all this has been obsoleted since then.

-- 
Tapio



  parent reply	other threads:[~2005-10-01 11:06 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
2005-10-01 11:06                       ` Tapio Kelloniemi [this message]
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