From: Richard Irvine <Richard.Irvine@eurocontrol.fr>
Subject: Value and reference, efficiency
Date: 1996/08/28
Date: 1996-08-28T00:00:00+00:00 [thread overview]
Message-ID: <322480A6.69DD@eurocontrol.fr> (raw)
In Smalltalk (as far as I understand) objects maniplated in programs
are in fact pointers. For example the result of
anObject := anotherObject.
is to have two pointers to the same piece of storage.
One has to be aware of this because if one goes on to
perform an operation which updates either of the
objects it will appear to have updated both of them.
(If this is not what is required one can do
anObject := anotherObject deepCopy.
in this case new storage is acquired, the data
is physically copied and anObject points to the
new storage.)
In Ada, if the objects are records then
anObject := anotherObject;
will result in a copy of the data being
made, so that subsequently updating one
object will have no effect on the other.
On the face of it one might expect that copying
of references would be more efficient than copying
of data.
In Ada one could replicate the Smalltalk way of
doing things and have objects which are in fact
pointers to dynamically acquired storage
and then just copy the pointer values on assignment.
(Now that controlled types are available one
could deallocate the storage automatically by
counting references.)
What I wonder is whether there is any significant
performance advantage to be gained from doing this?
reply other threads:[~1996-08-28 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox