From: mcsun!sunic!lth.se!newsuser@uunet.uu.net (Dag Bruck)
Subject: Re: User-defined assignment
Date: 19 Oct 92 07:55:46 GMT [thread overview]
Message-ID: <1992Oct19.075546.642@lth.se> (raw)
In <comp.lang.ada> 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
next reply other threads:[~1992-10-19 7:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-10-19 7:55 Dag Bruck [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-10-30 2:39 User-defined assignment Alex Blakemore
1992-10-29 18:20 Jack Beidler
1992-10-22 22:19 dog.ee.lbl.gov!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!darwin.su
1992-10-21 23:42 dog.ee.lbl.gov!hellgate.utah.edu!caen!zaphod.mps.ohio-state.edu!rpi!bu.ed
1992-10-20 15:12 Rick Hudson
1992-10-19 14:13 Douglas N. Surber
1992-10-19 7:31 Dag Bruck
1992-10-18 19:29 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!soft
1992-10-17 23:32 Tucker Taft
1992-10-17 17:57 dog.ee.lbl.gov!hellgate.utah.edu!caen!malgudi.oar.net!zaphod.mps.ohio-sta
1992-10-16 23:13 dog.ee.lbl.gov!hellgate.utah.edu!cs.utexas.edu!qt.cs.utexas.edu!news.Brow
1992-10-16 11:58 St ef Van Vlierberghe
1988-12-09 13:16 user-defined assignment Robert Firth
1988-12-09 20:35 ` David S. Rosenblum
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox