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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d80cdc1b3ff5b2f9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-14 23:26:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!lsanca1-snf1!news.gtei.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3BCA818F.161376A1@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Simple Question 3 References: <9q49v5$6dj$1@trog.dera.gov.uk> <9qcmt9$8n1$1@newsg1.svr.pol.co.uk> <3BC9FD23.ACEB872A@acm.org> <9qd2c9$4a2$1@news7.svr.pol.co.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 15 Oct 2001 06:26:38 GMT NNTP-Posting-Host: 206.133.138.102 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1003127198 206.133.138.102 (Sun, 14 Oct 2001 23:26:38 PDT) NNTP-Posting-Date: Sun, 14 Oct 2001 23:26:38 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sun, 14 Oct 2001 23:22:59 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:14498 Date: 2001-10-15T06:26:38+00:00 List-Id: Stephen Cole wrote: > > "Jeffrey Carter" wrote in message > news:3BC9FD23.ACEB872A@acm.org... > > > > We could perhaps be of more assistance if you could define what you > > expect the compiler to do for > > > > X : Mytesttype2 := Unitc; > > > > What is the value of X after initialization? Specifically, what is the > > value of X.C? > > > > -- > > Jeff Carter > > "I fart in your general direction." > > Monty Python & the Holy Grail > > I would have thought that the compiler would have looked for a function > called UnitC() that would return a type MyTesttype2. If it could not find > one then it would flag a static match failure and so the whole problem of > X.C being initialised would not have occured as it would not be allowed. Unitc is a primitive operation of the root type. Primitive operations are inherited by the child type if they are not overridden. However, the inherited version of Unitc cannot know about the additional components of the child type, so it must be overridden. Therefore, Ada requires the function to be overridden. The problem arises because a call to Unitc can still be a dispatching call. You cannot guarantee that all calls will be determinable at compile time. Therefore, a version of the function must exist for the child type. Of course, if you use composition rather than type extension and dispatching you can obtain the same effect but deal with these details however you like. The resulting software will be easier to read, as well. -- Jeff Carter "I wave my private parts at your aunties." Monty Python & the Holy Grail