Hi, Ted,
I would call this a little misunderstanding.
What is changing its state is not an integer value, as it seems to you, but
the word 'a (and, as a consequence, its alias 'c).
You can create a similar "paradox" even easier:
a: 1
a: a + 1
With the same reasoning, you might say, that you changed an "immutable"
scalar 1. The correct answer is different. You changed only the word 'a,
which had assigned integer value 1 at the first row and the integer value 2
at the second row. But you are not right saying that you "changed" the value
1 to 2, because the expression:
1 + 1
doesn't change the integer value 1. It only computes a new, fresh integer
value 2.
The last paradox you created can be rewritten like this:
a: "first"
b: a
same? a b
b: "second"
a
with the result:
>> a: "first"
== "first"
>> b: a
== "first"
>> same? a b
== true
>> b: "second"
== "second"
>> a
== "first"
and, even without copying, you may say, that A (meant as the string value
with the textual form "first" being assigned to the word 'a at the first row
of the example code) behaves like being "immutable" here. The correct
explanation is different: A behaves like being "immutable", because we
didn't try to modify it. The only thing we modified is the word 'b.
Regards,
Ladislav
> Ladislav,
>
> I think by default REBOL copies only the state of scalar values but
> makes an alias of series values. If I alias an "immutable" scalar
> value, it acts just like a "mutable" series value.
>
> >> a: 3
> == 3
> >> alias 'a "c"
> == c
> >> a: 4
> == 4
> >> c
> == 4
> >> same? a c
> == true
> >> unset 'a
> >> c
> ** Script Error: c has no value.
> ** Where: c
>
> >> a: "string"
> == "string"
> >> c: a
> == "string"
> >> a: "fancy"
> == "fancy"
> >> c
> == "fancy"
> >> same? a c
> == true
> >> unset 'a
> >> c
> ** Script Error: c has no value.
> ** Where: c
>
> Likewise, if I copy a string, it acts like a scalar value.
>
> >> a: "string"
> == "string"
> >> c: copy a
> == "string"
> >> c: "fancy"
> == "fancy"
> >> a
> == "string"
>
> I don't believe that REBOL means to keep us from changing DATE! and
> TIME! (or TUPLE!) values, as Joel demonstrated. This is probably a bug
> and should be reported as such.
>
> It's true that series values are not simple, and REBOL sometimes shows
> us only the head or tail of the series at the console (as in your
> original "probe" example). It's also true that for scalar values, same?
> and equal? seem redundant. Perhaps that is a design flaw. I also think
> that empty? is not defined the best way. Perhaps same? should only
> return true when two scalars are alaised, and not just equal. (Is there
> any way to tell when two scalars are aliased? (without changing their
> value))
>
> -Ted.
>
>
>
>