[REBOL] generalities of addresses and values... Re:(3)
From: brett:codeconscious at: 10-Oct-2000 18:39
> ok. I think I get it now. Everything is basically done as a reference.
Even setting words. This is much simpler than what I was thinking :-)
Um...
> a: 5
> b: a
>
> in this example, b is a reference to a (right?).
Nope. b is set with the result of evaluating a.
>> a: 5
== 5
>> b: a
== 5
>> a: 3
== 3
>> a
== 3
>> b
== 5
> The thing that was confusing me was that the copy function doesn't always
create a new copy. In deep series, it creates a reference to copied
value....strange...
> By the way, is there any way to prove that b is a reference to a ( in the
above example) ? I know you can do it if you set the value of as a series
datatype (by using insert or other series function). But how do you prove
that b references a for number datatypes?
I showed above that b is not a reference to a.
Here's another way to look at it.
You could set the word "b" to have a value which is literally the word "a" -
by doing this:
>> b: 'a
== a
You could then see the value of the word "b" by
>> get 'b
== a
or evaluting b
>> b
== a
and combining
>> get b
== 3
Which evaluates b to a value, in this case a word, and then applies the get
function to that value.