Hi, Ladislav,
I think the key point is that REBOL is polymorphic and handles scalar,
series, and constructed values in different ways.
We are told that REBOL unsets a word before setting it. So then it must
be true that I cannot change the value, I can only set the word to
another value.
In the case of scalars, I guess you are saying that there is only
really one "instance" of each scalar value, and any word with that
state refers to that one "instance". (No flames on the term instance,
please.)
This would be because all scalar values can be predefined, since that
is what scalar means. And this is why all scalars with the same
apparent state are considered both the same and equal. In REBOL-space,
there is only one integer value 2.
In the case of series (and I suppose constructed) values, the data
value is arbitrary and cannot be predefined. So, two strings with the
same apparent state are equal, but may not be the same. Since the data
value is something we created, we can change it (it is mutable). But we
don't really change scalar values, we simply reset the word to another
(predefined) scalar (it is unmutable).
In the case of Joel's examples with TIME! - TIME! is a scalar. You
cannot change a scalar value the way you can change a series value
(immutable vs mutable). You must reset the word to another scalar. So,
>> a/minute: 55
== 7:55:02
Is not enough to change 'A -- we must say
>> A: a/minute: 55
== 7:55:02
to set A to a new value. This is because A/MINUTE returns a scalar
value, the assignment conveniently adjusts that scalar value, and
returns that result. But since A is scalar, REBOL does not
automatically redefine A.
With a series, the same operation returns a reference to the data, and
so A (as a string) would be automatically changed (it is mutable). If
we want to avoid that change, we must copy the series first.
By default, REBOL sets a word to share the data of a series value. I
don't know if this is a theoretical necessity, or just an
implementation decision to save space. After all, if series acted like
scalars, then we would be forever making copies of what could be very
large structures.
-Ted.