From: Samuel Mize <[log in to unmask]>
> I personally wouldn't limit the term "language construct" to
> syntax-level entities, so I can agree with both of you.
I think Robert and I agree with each other, so...
> - You don't see a syntax-level "thing" that encapsulates a class.
> - Robert sees a semantic "thing" that provides the functionality
> of a class (abstraction, inheritance, polymorphism, etc.)
Mm-hmm. Me too.
> For this reason, Ada has a PR problem among people who look at the
> very shallowest surface of the language. Some people in the Ada 9X
> process argued strongly that Ada 95 should have a keyword or
> syntax construct called "class," just to make it easier to sell
> the language's O-O features -- for absolutely no technical reason.
> I feel the Ada construct is the right technical choice. The
> fact is that Ada's system is MORE powerful.
> - To fully and formally encapsulate classes, you use Ada's
> encapsulation mechanism -- the package. Put each class in
> its own package.
> - To tightly couple some classes, you can put them into the
> same package, so each can see the other's implementation.
> (This is often a bad idea, but it is occasionally quite
> useful -- rather like keeping GOTO in the language.)
> - I have also used tagged types to simplify coding in a purely
> procedural program. From what I've read about typical C++
> usage, this is not uncommon -- but in C++ it's more confusing,
> because you have to define bogus "classes" for non-objects.
Yes to all that. Well put.
There's also the fact that in C++, dispatching is coupled to whether the
call is by reference or by value, which seems arbitrary and encumbering.
In Ada, control over dispatching is orthogonal to reference/value
> Note that I'm not a O-O totalitarian. Some people thing
> EVERYTHING should be object oriented, NOTHING should be
> procedural. They will knock a language that lets you organize
> your design in any other way.
> I personally think that's hogwash, and I very much like the
> integrated procedural and object-oriented facilities of Ada.
Right. I think pure OO was an interesting way to explore the concepts
of encapsulation, inheritance, and polymorphism. Those concepts aren't
ends in themselves but techniques for making programs better. I would
say that good factoring, good cohesion and appropriate coupling are ends
in themselves. I could be dogmatic about those...
Alexander Stepanov (of C++ STL fame) notes that saying
"everything is an object", like other philosophies that claim
"everything is an X", isn't that interesting and is of little use.
It's inherently question-begging. When someone says "everything is an
X", they haven't said all that much, 'cause we already know what
"everything" means... :-);
Q. What did the Zen monk say to the hot-dog man?
A. "Make me one with everything!"