TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Fri, 1 May 1998 17:14:00 -0400
text/plain (18 lines)
For the special case where objects don't have 'invalid' states, but
come fully into existence and stay, in a stack-like way, until they
die, and where Ada 95's discriminant limitations don't cause
difficulties, it would, IMHO, be desirable to use constructors rather
than Create functions.
is simpler than
   X:Object_Type := Create(params);
and does not even have the possibility of forgetting the initial
value assignment, or doing an erroneous later assignment.  If
Create needs to be a procedure, not a function, then
may leave the coder open to the possibility of erroneously invoking
the inherited Create of Parent_Type instead of a proper new Create -
with additional parameters - of the Child_Type.