From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,82c7a4dae672250f X-Google-Attributes: gid103376,public From: Jean-Pierre Rosen Subject: Re: "Object" types vs. "Value" types Date: 1996/03/25 Message-ID: <199603250902.KAA21800@email.enst.fr>#1/1 X-Deja-AN: 144161909 sender: Ada programming language x-sender: rosen@email.enst.fr comments: Gated by NETNEWS@AUVM.AMERICAN.EDU content-type: text/plain; charset="us-ascii" mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Windows Eudora Light Version 1.5.2 Date: 1996-03-25T00:00:00+00:00 List-Id: 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-------------------------------------+