From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e2db8edf2656165 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!newsfeed.stueberl.de!news.germany.com!newsfeed.kamp.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Constructing an object Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1lw8oz33ao529.12ep5ay7rg4oc$.dlg@40tude.net> <5-GdnRjCgYZOfKneRVn-qw@megapath.net> <3dachnu33lly.fpr0wvf6nj05$.dlg@40tude.net> <88m4nn9wh78b$.1wtlfwjymgcom.dlg@40tude.net> Date: Sat, 1 Oct 2005 12:49:27 +0200 Message-ID: <1h1ooovh0igvo.1ea57ledo3rrc.dlg@40tude.net> NNTP-Posting-Date: 01 Oct 2005 12:49:13 MEST NNTP-Posting-Host: d43b6c09.newsread4.arcor-online.net X-Trace: DXC==eJ9h3KD74B?_CdR_9TKXA:ejgIfPPldDjW\KbG]kaMHXY;eg@jLYeLG7I848_8HFB[6LHn;2LCVNI^><>f3dFYJ1VDHiG7IG@@ X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:5321 Date: 2005-10-01T12:49:13+02:00 List-Id: 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