From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 19 Oct 92 07:55:46 GMT From: mcsun!sunic!lth.se!newsuser@uunet.uu.net (Dag Bruck) Subject: Re: User-defined assignment Message-ID: <1992Oct19.075546.642@lth.se> List-Id: In stt@spock.camb.inmet.com (Tucker Taft) writes: > >Assignment is used implicitly in subprogram calls for by-copy parameters, >in creating aggregates, in explicit and implicit initialization, on >function return, in assignment for composite types, >etc. C++ makes a very clear distinction between creation and assignment: - constructors create an object in a piece of storage with no existing content (except random bits) - assignment changes the content of existing well-defined object This distinction seems to be missing from the current discussion in comp.lang.ada. In my view it is a fundamental distinction that also has practical ramifications for the programmer. For example, an ADT which uses shared representation in its implementation may have to create a copy of the underlying data when a new value is assigned. To create a new object with same value, the underlying data may be shared. Argument passing in C++ is not done by the assignment operator; it is done by the "copy constructor" which creates a copy of an existing object. >Of course, this is not as friendly or flexible as being able >to define ":=" for any type, and having it used automatically >everywhere it is appropriate. However, it is significantly >easier to implement, ..... Hmmm. I see this as a syntactic issue. Why would user-defined ":=" be harder to implement that user-defined "Assign(....)"? Would it be hard for the compiler to know what ":" to use? Or do you mean that it would be hard for the user to write a ":=" that meets the semantic demands of all compiler-generated uses of ":="? In any case, in my view bit-wise ":=" is almost always wrong for non-trivial data types. -- Dag