comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: "Object" types vs. "Value" types
Date: 1996/03/25
Date: 1996-03-25T00:00:00+00:00	[thread overview]
Message-ID: <dewar.827756328@schonberg> (raw)
In-Reply-To: 199603250902.KAA21800@email.enst.fr

"1) "Value semantics" if Y:=X means that the contents of X is copied into Y.
2) "Reference semantics" if Y:=X means that from now on, X and Y designate
the same object."

I think this can be a bit confusing, because it describes what are high
level notions in terms of one particular implementation approach.

Now of course, "as if" applies, so what is meant for example is that
"Value Semantics" if Y := X means that it is AS IF the contents of X
 is copied into Y.

Why is the distinction important. Well a standard, and often efficient
way of achieving value semantics is to copy on modification, rather
than copy on assignment. 

In this model the value is represented by a pointer and indeed the
assignment copies the pointer so that the original and the assigned
object both "reference the same object" at the implementation level.

However, if either is modified, it is copied before modification, so
that there is no sharing from a logical point of view.

It is the visible sharing that is the issue here, i.e. after the assignment
A := B, can a subsequent modification to any aspect of A affect any aspect
of B and vice versa. If the answer is NO, then we have value semantics,
if YES, then we have reference semantics.

The distinction is indeed critical, but no wonder you got confused talking
about assignment if you immediately started talking about low level
implementation details (use of pointers, and copying of values on
assignment). You need to describe the difference at an operational
semantic level, as I have done here, rather than at an implementation
level.





  reply	other threads:[~1996-03-25  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-25  0:00 "Object" types vs. "Value" types Jean-Pierre Rosen
1996-03-25  0:00 ` Robert Dewar [this message]
1996-03-26  0:00 ` Michel Gauthier
1996-03-27  0:00   ` Richard A. O'Keefe
1996-03-27  0:00     ` Robert Dewar
1996-03-27  0:00 ` Michel Gauthier
  -- strict thread matches above, loose matches on Subject: below --
1996-03-26  0:00 Jean-Pierre Rosen
1996-03-15  0:00 Comments on generic stack? Michel Gauthier
1996-03-20  0:00 ` "Object" types vs. "Value" types John G. Volan
1996-03-20  0:00   ` John DiCamillo
1996-03-21  0:00     ` Comments on generic stack? John G. Volan
1996-03-21  0:00   ` "Object" types vs. "Value" types david scott gibson
1996-03-25  0:00     ` John G. Volan
1996-03-28  0:00       ` david scott gibson
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox