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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b74ec64483660e21 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-24 06:39:19 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!212.74.64.35!colt.net!newspeer.clara.net!news.clara.net!btnet-peer!btnet-peer0!btnet!psiuk-p2!uknet!psiuk-n!news.pace.co.uk!nh.pace.co.uk!not-for-mail From: "Marin David Condic" Newsgroups: comp.lang.ada Subject: Re: When to use 'Class in a parameter list Date: Tue, 24 Jul 2001 08:49:36 -0400 Organization: Posted on a server owned by Pace Micro Technology plc Message-ID: <9jjqt0$o1s$1@nh.pace.co.uk> References: <9ji1b3$4pi$1@nh.pace.co.uk> <9ji5j7$hlu$1@news.huji.ac.il> NNTP-Posting-Host: 136.170.200.133 X-Trace: nh.pace.co.uk 995978976 24636 136.170.200.133 (24 Jul 2001 12:49:36 GMT) X-Complaints-To: newsmaster@pace.co.uk NNTP-Posting-Date: 24 Jul 2001 12:49:36 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Xref: archiver1.google.com comp.lang.ada:10512 Date: 2001-07-24T12:49:36+00:00 List-Id: "Ehud Lamm" wrote in message news:9ji5j7$hlu$1@news.huji.ac.il... > > type? I was under the impression that I would use 'Class if I wanted to > make > > an operation that worked on anything derived from the class without > explicit > > conversion. (Possible to override it in a child class, AFAIK...) > > > You mean _impossible_ right? > Uhhhh Dunno... I seem to have a procedure at one level that takes an Object'Class parameter and I overrode it one level up with an identical procedure taking an Object_Child'Class. The compiler didn't complain and the code appears to work. Maybe it shouldn't, but there you have it... > Basically if you want overriding to be an option you use a primitive > operation. Notice that you have to think about the possible evolution of the > system, not about how things work the first time around. > Primitive operation? What do you mean? Like if I have a "procedure C (Obj : in out Object);" as opposed to "procedure C (Obj : in out Object'Class);"? > The main question is not about the conversion, but whether calling the > routine requires run-time dispatching. (essentialy, the class-wide routine > doesn't need dispatching). The Rationale has a couple of tables that nicely > show the dispatching/non-dispatching semantics of the various parameter > lists. > O.K. So if I make it a 'Class, it does not require runtime dispatching? The compiler knows from the type that it can simply degenerate to the specific operation, rather than jump to a dispatch table? And if I override the 'Class operation (it *seems* to work!) with a new 'Class operation, the compiler can tell from the data type what to jump to? > It may be helpful to think of class-wide routines as a language incarnation > of the "template method" design pattern. They allow you to specify a general > alogirthm that may work differently on different derived types, by invoking > dispatching routines. > (Now, I must admit, this would work better with MI, but MI is evil...) > Now you've got me thinking it should dispatch. Does it or does it not? I sort of conceptualized the 'Class operations (based on examples from a couple of books - which I badly need to re-read apparently! :-) as "This procedure should work on anything derived from this class because it only operates on the base-level components and generally should not be something that is overriden". Whereas, the operations on some base type without the 'Class operation seemed to be saying to me "O.K. This operation works on the base type, but you will probably be overriding it to provide additional capabilities when you derive a child type." Perhaps my conception of this is inaccurate... Maybe you can help me get my brain straightened out about this. I vaguely remember understanding this a couple of years ago when I was last fooling with it, but not having used it recently or enough, it is confusing me again. MDC -- Marin David Condic Senior Software Engineer Pace Micro Technology Americas www.pacemicro.com Enabling the digital revolution e-Mail: marin.condic@pacemicro.com Web: http://www.mcondic.com/