Fri, 1 May 1998 17:14:00 -0400
|
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.
X:Object_Type(params);
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
X:Child_Type;
begin
Create(X,params);
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.
|
|
|