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: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: "Object" types vs. "Value" types Date: 1996/03/25 Message-ID: #1/1 X-Deja-AN: 144170948 references: <199603250902.KAA21800@email.enst.fr> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-03-25T00:00:00+00:00 List-Id: "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.