Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!gatech!howland.reston.ans.net!ix.netcom.com!netcom.com!netcom4!haahr
From: haahr@netcom.com (Paul Haahr)
Subject: Re: Silly question.
In-Reply-To: aberno@genome.stanford.edu's message of Tue, 07 Mar 1995 16:02:13 -0800
Message-ID: <HAAHR.95Mar8133756@netcom4.netcom.com>
Sender: haahr@netcom4.netcom.com
Organization: Harlequin, Ltd.
References: <aberno-0703951602130001@lyapunov.stanford.edu>
Date: Wed, 8 Mar 1995 13:37:56 GMT
Lines: 36

aberno@genome.stanford.edu (Anthony Berno) writes:
> I understand that variables are actually references, so that if you say
> 
> let a = make(<point>);
> let b = a;
> b.horizontal := 2;
> a.horizontal := 3;
> print (b.horizontal);
> 
> the output is 3, since b it is one and the same object as a.

Variables aren't references, at least in the C++ or Pascal meaning of
the term.  What you're observing is that objects are not copied on
assignment, so a and b are ``pointing at'' the same object, and when it
changes, that can be noticed through either route to the object.

> But, if you
> do the following:
> 
> let a = 0;
> let b = a;
> b := 2;
> a := 3;
> print (b);
> 
> you get an output of 2. So, there is something different about numbers.
> But, numbers are supposed to be objects, right? This is a pure object
> system, right? So why are they being treated differently?

They're not being treated differently.  In this case, a and b are
``pointing at'' different integers.  The same thing would happen for
points or any other class.

Another way to look at this is that in the first example, you're
modifying the slots of an object, where in the second you're only
assigning to variables.  Numbers have no (user visible) slots.
