{{
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.)
}}
Or, REBOL only creates one object for a given scalar value, and all
words defined with that value refer to the same object.
In the case of a series, REBOL creates an object for the data value,
and by default, shares the data value when a word is set to the series.
Many series operations don't need to reset the word, since the
operation affects the data value directly. The word is still defined
the same way, but evaluates differenty because the value of the
underlying reference has changed. (It looks-up the data value and
finds a different string, but it is still looking at the same memory
location.)
In the case of a scalar, you must reset the word for it to evaluate to
another value. Scalars are immutable -- the underlying object cannot be
changed, we must reset the word to refer to another object.
Are we getting any closer?
-Ted.
*********** REPLY SEPARATOR ***********
On 1/4/2000 at 7:16 AM [EMAIL PROTECTED] wrote:
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.