From: dave@alex.uchicago.edu (Dave Griffith)
Subject: Re: Object hidden state and side effects
Organization: University of Chicago
Date: Wed, 16 Dec 1992 17:51:26 GMT

In article <1992Dec16.65250.10645@kei.is.s.u-tokyo.ac.jp> jeff@is.s.u-tokyo.ac.jp writes:
>In article <1992Dec15.014420.6604@midway.uchicago.edu> dave@alex.uchicago.edu (Dave Griffith) writes:
>
>{ whole bunch of stuff about modelling deleted }
>
> |>If the bits can change and move, then I don't see the diff between
> |>"value" and "object that does not change".  In short, why can't a
> |>value be an object?  What does explicitly knowing/using the fact that
> |>something does not change help us?
> |
> |It _does_ allow a lot of optimization.  There are occasions where copy
> |semantics are cheaper than reference semantics.  But at a higher level, it 
> |seems to be necessary to allow safe programming.  We need to know that noone 
> |can subclass our Integer class so as to allow the old Fortranism of changing 
> |3 to 5.
>
>I realize that it allows optimizations but to be honest, from a
>programming/design point of view I don't want to know about the
>implementation.  That is what we are fighting against.  Having to know
>and explicitly use implementation detail.

You deleted the modelling stuff, which provided the semantic background, and 
ignored all but the first two sentences of the stuff that you did quote. 
Actually, the distinction between copy semantics and reference semantics is 
_not_ an implementation detail.  It is a central part of the design of
any language which has assignment or procedure call.  "Objects" as I have
been using the term use reference semantics.  Two objects are only equal if
they are identical.  "Values" use copy semantics for assignment. (What they
use for equality semantics is a deeper and IMHO more interesting question, but 
I digress.)  How these semantics are actually implemented is a implementation
decision and should not be considered here.  

>
>I feel sort of like there is misunderstanding in this thread.  At some
>point someone said that a value is not an object (or something like
>that) and that it was bad to 'pretend' that it is.  Was that you?  Do
>you agree with the statement?  If so why?

Not me, but I do agree.  I feel that the distinction between values and 
objects is a fruitful one which is only supported with difficulty in many
current OO languages.  Valuable and important meaning is lost in implementing
values as objects.

>
>I am really at a loss here.  What exactly (in concrete real terms) do
>you expect people to do differently when using true for example once
>it is recognized as a value and not an object?
>

Express their actual intent clearly and precisely, without requiring 
unneccessary contortions to map their intent to a overly limitted language.
But I've always been a dreamer.

> |Whether the actual bits are changable is rather beside to point.  The idea
> |is that a values essential nature cannot change, whatever that means.  This
> |is usually easiest if the bits are unchanging, but that is not necessary.
>
>
>If you want to have "essentially the same" objects great!  That's just
>a differnt kind of object.  Perhaps your compiler can do something
>special.  Great.  As a designer of large systems I don't want to know
>about it.  They are just objects to which I can send messages, pass as
>parameters...  They have a protocol... and allow only those operations
>that are in line with their "essential sameness"

But most languages have no way to _enforce_ the requirement that they "only
allow operations that are in line with their essential sameness".  They
treat their builtin classes as "special", and don't allow programmer defined
classes to be defined as special in the same way.  It would be useful in C++
for instance to define a Bignum class which didn't allow the programmer
to set 3 equal to 5, even if that Bignum class is eventually subclassed.  
Subclassing can blow away the original programmers intent of immutability, 
with possibly disastrous effects on program correctness.


-- 
Dave Griffith, Information Resources, University of Chicago,
Department of Surgery                       dave@alex.bsd.uchicago.edu
Oh, by the way, I almost forgot.  Godot called.  He said he'd be late.
Newsgroups: comp.object