I like to call attention to an article "Implementing Constructor Calls
with Parameters in Ada 95" by Z. Bayram in May '98 issue of JOOP.
My pleasure at seeing an Ada article in this widely read magazine is
tempered by my feeling that the article suggests a notion that I think
is not very well considered, and that I think misses a point about
Ada's OO techniques. I'm sending this brief note to Team Ada in hope
that a) if my displeasure in Bayram's tactic is inappropriate, one of
my friends will enlighten me, or b) wiser disputants than myself will
write a rejoinder to the article and show a more-Ada-like tactic for
"constructing" objects.
Bayram seems to be enthusiastic about some other language's ability to
encode "automatic object initialization." He "wish[es] designers of the
Ada 95 standard had thought of a better way than the package
Ada.Finalization for implementing object initialization. We do not
hesitate in suggesting a solution: slightly incrementing the syntax of
the languageŠ"
So instead of defining a primitive function Create that would carry
parameters needed order to initialize private components, he elects to
derive his type from limited_controlled for the sole reason that this
allows him to pass the type's discriminants to an implicit
initialization procedure. And this in turn leads him to declare an
otherwise unneeded access type.
I was pretty disappointed in this, because he then proceeds to expose
all the components (or at least proxies to the components) of the
private type in a declaration of every object.
I think this article shows two things: a) it's possible to write
less-than-good programs, even in an excellent language, and b) a reader
who might want to find fault with Ada will have another example of
"over complicated, extreme restrictiveness" to cite. What's worse, the
less-than-good example program is the one that gets published in the
magazine, and the successful work-a-day Ada programs languish in
oblivion.
John