comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@EMAIL.ENST.FR>
Subject: Re: "Object" types vs. "Value" types
Date: 1996/03/25
Date: 1996-03-25T00:00:00+00:00	[thread overview]
Message-ID: <199603250902.KAA21800@email.enst.fr> (raw)

At 01:31 20/03/1996 GMT, you wrote:

> [...]
>In light of these notions, I long ago came to the conclusion that, as
>far as programming was concerned, there was a useful distinction to be
>made between two sorts of data types: "object" types and "value"
>types. An "object" type is a data type for which the distinction
>between "identity" and "state" was strong, whereas a "value" type would
>lack this strong distinction.
>
> [lots of valuable stuff deleted]

This subject was raised at one of the  Ada-France meetings, when  Michel
Gauthier came and said "Hey guys, I don't know what an assignment statement
does". We told him "sit down, we'll explain to you". Two hours of discussion
later, nobody knew anymore how to define the semantics of assignment...

However, we came to the conclusion that there were two cases where the
semantics of assignment could be defined, and this is very close to what you
said.

Given a (private) type, and two variables X and Y, we say that the type has:

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.

1) is for "usual" values, 2) is for pointers of course, but also any other
kind of reference (like the (private) type being actually a string used as
an entry in a symbol table).

Note that there is no syntactic way (without looking at the private part) to
tell which semantic a private type has : it has to be commented.

An important consequence of this finding is that you should never mix in a
record fields with "value" semantics and fields with "reference" semantics;
if you do, it is impossible to give a simple semantics to assignment for
objects of this record type.

The issue of limited types is a bit different. Limited types (and controlled
types) are useful when the predefined assignment would have the wrong semantic.

This issue is discussed at length in my book, and in several of Michel
Gauthier's publications (I don't have the reference at hand, but he will
tell you if you want).
+------------------------------------o-------------------------------------+
| P-mail:                            | E-mail: rosen@enst.fr               |
|   ADALOG - 27 avenue de Verdun     |    Tel: +33 1 46 45 51 12           |
|   92170 Vanves - FRANCE            |    Fax: +33 1 46 45 52 49           |
+------------------------------------o-------------------------------------+




             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 Jean-Pierre Rosen [this message]
1996-03-25  0:00 ` "Object" types vs. "Value" types Robert Dewar
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