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,782af4edeb84c4b7 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news.glorb.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: basic basic ada question Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.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: <1161268231.345231.242170@m73g2000cwd.googlegroups.com> <4537bc65_1@newsfeed.slurp.net> <5567b72ia0c9$.1b6yl0tpfscj5$.dlg@40tude.net> <13bxqw4vydm93$.vlnod0hnsogo.dlg@40tude.net> <2lh16y6eetpr.174c6t4885tws$.dlg@40tude.net> Date: Mon, 23 Oct 2006 11:21:55 +0200 Message-ID: <1003e77ytohm0$.1kiriiggzo76m.dlg@40tude.net> NNTP-Posting-Date: 23 Oct 2006 11:21:55 CEST NNTP-Posting-Host: 33b53862.newsspool4.arcor-online.net X-Trace: DXC= On Mon, 23 Oct 2006 09:45:31 +0200, Maciej Sobczak wrote: > Dmitry A. Kazakov wrote: > >> That's why it should be a class-wide constructor. You construct first a >> specific object, then its class it constructed. At this point you can >> dispatch, because the specific object is already sane. This applies only to >> the tagged types which have class views and class-wide objects. So when you >> construct either, first T is constructed and after that T'Class. If S were >> derived from T, then construction of S could look like: >> >> 1. T's components >> 2. S's components >> 3. T (Initialize) >> 4. S (Initialize) >> 5. T'Class >> -- here a class-wide constructor defined for T can safely dispatch to a >> -- some primitive operation overridden by S >> 6. S'Class >> >> [I am not sure about ordering 5 and 6] > > And I am not sure why do you need 5 and 6 at all - you've already done > the whole job in 3 and 4. You cannot dispatch to the procedures of S from Initialize of T, i.e. from 3 before 4 is done. S might be unusable. The step 5 is for this purpose. > Note also that having all these points (3-6) opens wide opportunities > for duplicated actions and other maintenance nightmares. It is difficult to say. In Ada there is a clean distinction between T and T'Class. So many things will be difficult to duplicate without an explicit type conversion. Normally, actions called from 5 would be abstract primitive operations. You'll get a compile error calling them from 3. Same with class-wide operations. > For me 4 should > be the last step and 5,6 should not exist at all. Which is indeed a maintenance disaster. Consider GUI interfaces built in C++. Note that practically all of them have procedures like OnInit, because it is eventually impossible to construct widgets fully functional. Ada suffers this as well. For example, it is impossible to embed task components. You need special Start/Stop entries in the tasks. I see this as a consequence of incomplete construction model which does not allow to define actions on the class. [ OnInit is that sort of action. Presently, you have to be call it manually, and you have a composition problem of many OnInit's along the inheritance chain.] > And you could safely change the order for 2 and 3. I think so. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de