TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Proportional Font
Show HTML Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Tucker Taft <[log in to unmask]>
Fri, 1 May 1998 10:15:42 -0400
text/plain (25 lines)
I agree that it is unfortunate that people have equated
C++ constructors with the "Initialize" procedure of
controlled types.  They really have little in common.
The "Initialize" procedure is somewhat related to the
"default" (parameterless) constructor, but even there,
it is rarely needed, because normal default initialization
in Ada is usually sufficient to accomplish what a C++
default constructor does.

Parameterized constructors in C++ or Java are best represented
by functions or procedures in Ada.  Ada 95 allows a type
to be declared in a way that you must explicitly initialize
all instances, by using the "unknown discriminants" notation
in the private type declaration.  This then allows any
function that returns the type to be used as a parameterized
constructor.

Oh well...

If anyone is interested in writing a comment on this article,
I hope it will be "upbeat" in saying that in addition to
the mechanism suggested in the article, Ada 95 also provides
a much more flexible mechanism based on functions and/or procedures.
-Tuck

ATOM RSS1 RSS2