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=-1.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2e2db8edf2656165 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!atl-c02.usenetserver.com!news.usenetserver.com!newscon02.news.prodigy.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder2.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail From: Tapio Kelloniemi Subject: Re: Constructing an object References: Newsgroups: comp.lang.ada Message-ID: <05u%e.31514$176.27928@reader1.news.jippii.net> Date: Sat, 01 Oct 2005 11:06:36 GMT NNTP-Posting-Host: 217.30.176.187 X-Complaints-To: newsmaster@saunalahti.com X-Trace: reader1.news.jippii.net 1128164796 217.30.176.187 (Sat, 01 Oct 2005 14:06:36 EEST) NNTP-Posting-Date: Sat, 01 Oct 2005 14:06:36 EEST Organization: Saunalahti Customer Xref: g2news1.google.com comp.lang.ada:5322 Date: 2005-10-01T11:06:36+00:00 List-Id: "Randy Brukardt" wrote: >"Robert A Duff" 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