comp.lang.ada
 help / color / mirror / Atom feed
From: "Marin David Condic" <marin.condic.auntie.spam@pacemicro.com>
Subject: Re: When to use 'Class in a parameter list
Date: Tue, 24 Jul 2001 08:49:36 -0400
Date: 2001-07-24T12:49:36+00:00	[thread overview]
Message-ID: <9jjqt0$o1s$1@nh.pace.co.uk> (raw)
In-Reply-To: 9ji5j7$hlu$1@news.huji.ac.il

"Ehud Lamm" <mslamm@mscc.huji.ac.il> 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/






  reply	other threads:[~2001-07-24 12:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-23 20:27 When to use 'Class in a parameter list Marin David Condic
2001-07-23 21:39 ` Ehud Lamm
2001-07-24 12:49   ` Marin David Condic [this message]
2001-07-24 14:39     ` Dmitry A. Kazakov
2001-07-24 15:16     ` Ehud Lamm
2001-07-24 17:16       ` Marin David Condic
2001-07-23 22:55 ` Stephen Leake
2001-07-25 19:20   ` Deligation with Ada95 Hans-Olof Danielsson
2001-07-26  2:06     ` Lao Xiao Hai
2001-07-24  2:22 ` When to use 'Class in a parameter list Vincent Marciante
2001-07-24 12:52   ` Marin David Condic
2001-07-24 14:36     ` Ed Falis
2001-07-24 15:29       ` Ehud Lamm
2001-10-29 22:52 ` Matthew Heaney
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox