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 Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news.osn.de!diablo1-ffm.news.osn.de!noris.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="iso-8859-1" Content-Transfer-Encoding: 8bit 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: Fri, 30 Sep 2005 21:28:34 +0200 Message-ID: NNTP-Posting-Date: 30 Sep 2005 21:28:22 MEST NNTP-Posting-Host: 191878c9.newsread2.arcor-online.net X-Trace: DXC= On Fri, 30 Sep 2005 10:14:47 +0200, Jean-Pierre Rosen wrote: > Randy Brukardt a �crit : >> "Dmitry A. Kazakov" wrote in message >>>They aren't extensible in the sense that you can only override or inherit. >>>It is too dangerous for constructors and assignments. BTW, Ada does not to >>>completely override them anyway. For example the parts responsible for >>>initialization of the components cannot be overridden. One cannot have a >>>task component which will not start because Initialize does not call the >>>parent's one! (:-)) >> >> Ah, I see. Certainly you are right here. I see that a lot in Finalize >> routines; it is real easy to forget to call the Finalize for the parent >> type. There ought to be a better way of extending rather than replacing >> routines; that's especially true since requires an explicit type conversion >> to the parent to make that call, and it is easy to get wrong (and go >> infinitely recursive). >> > I think CLOS has such a feature, but it raises an issue: > sometimes you want to call the parent Finalize *before* your own > Finalize, sometimes *after*. If it is automatic, you must force one of > them, which makes problems if you want the other one. Yes, but I almost sure that this one is rooted in an incompleteness of the construction model. If we consider T and T'Class as different types, then we should consistently conclude that they might have constructors of their own. (Of course T'Class destructor includes one of T.) I wonder if all cases when one needs to call parent's Finalize out of order, are actually ones which should be handled by the Finalize of T'Class. Now because class-wide objects should be finalized before all specific ones, Finalize of T'Class would be called before Finalize of any S derived from T. One could even safely dispatch from it! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de