From: "Robert I. Eachus" <[log in to unmask]>
Date: Thu, 12 Nov 1998 17:46:47 -0500
Subject: Re: No "class" construct in Ada (was Re: Ada in CFD)
> At 01:12 PM 11/12/98 -0800, Mark Lundquist wrote:
> >> Adding special notation for declaring classes in Ada would have created
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >> either some unnecessary restrictions or backward compatibility problems.
> >
> >Yes -- that is the position I was taking. My use of the phrase "special
> >class construct" is to be understood as identical with your phrase
> >"special notation for declaring classes".
>
> Okay. If you regard "a package specification containing a single tagged
> type declaration and declarations of operations on that type," as equivalent
> to a class in other languages, you could consider that as a special class
> construct.
Close -- I regard the tagged type declaration plus the primitives as the
class definition, whether or not the package contains anything else. As
you rightly state, a package can declare more than one "class".
I have seen a style of Ada that attempts to slavishly emulate
class-oriented macrostructure. That style does make a 1-1 association
between packages and classes, going so far as to name the package after
the class and then always naming the type itself "Object", e.g.
-- Class Fribbitz
--
package Fribbitz is
type Object is tagged private;
--
-- bah, bah, bah...
--
end Fribbitz;
Some people think that's great. I don't particularly care for it. But
that's just my taste...
> But part of my point was that having a "special notation" would
> have eliminated the possibility of defining several classes/tagged types
> in the same package. Because of this--and the 'Class operation you can
> create classes that are closely intertwined. (It would be nice to be able
> to easily create such mutually interdependent types in different packages,
> but that is a different discussion.) Of course, there is a rule preventing
> operations from being dispatching operation of more than one tagged type,
> but that is needed for
> other reasons.
>
> Robert I. Eachus
Right. As far as I can tell, we are both saying that (a) Classes are
easily implemented in Ada, even though (b) Ada doesn't have a "class"
syntax that is like C++/Java, but (c) a C++/Jave-like "class" syntax
wouldn't be such a great idea for Ada, for a number of reasons,
and moreover (d) we like it way it came out in Ada better anyway.
-- Mark
|