TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text 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:
Reply To:
Date:
Fri, 1 May 1998 17:14:00 -0400
Content-Type:
text/plain
Parts/Attachments:
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.
   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.

ATOM RSS1 RSS2