TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

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

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

Print Reply
Subject:
From:
Tucker Taft <[log in to unmask]>
Reply To:
Tucker Taft <[log in to unmask]>
Date:
Fri, 1 May 1998 10:15:42 -0400
Content-Type:
text/plain
Parts/Attachments:
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