Hi --

On Thu, 19 May 2005, Eric Mahurin wrote:

> --- "David A. Black" <dblack / wobblini.net> wrote:
>>
>> To a large extent, my reaction to all of these examples comes
>> down, as
>> it often does, to the question: how would I explain this to
>> someone to
>> whom I was teaching Ruby (in person or in writing)?  I think
>> I would
>> find it quite difficult to explain that in this:
>>
>>    s = "hi"
>>    t = s
>>    (s) = "bye"
>
> I think this is a good example to show the difference.
> Programmers need to understand the difference shown above.  One
> assigns to a variable and one assigns into an object that a
> variable has.  Both are normal things you would want to do and
> both are assignment-like.

There's no checklist of "normal things" in this context.  Programming
languages are allowed to be designed differently :-)

In Ruby's object/reference (variable) model, changing the object via
assignment is *not* normal, and not something I would want to do.
Assignment is to variables, and variables hold references to objects
(or, in some exceptional cases like Fixnums, they are immediate
values).

> Why do some of you think that everything I suggest has to do
> with references?

I don't think that of everything you suggest, but in this case:

   s = "hi"
   (s) = "bye"   # changing the object to which s is a reference

it seems to be clearly a way of adding that extra level of remove.


David

-- 
David A. Black
dblack / wobblini.net