[REBOL] Re: On mutability and sameness
From: jeff:rebol at: 19-Jun-2001 10:44
Hello, Robbo:
> JEFF,
>
> I essence you are correct, but how easier can you more
> properly explain these examples.....
>
> >> a: "123"
> == "123"
> >> b: a
> == "123"
> >> c: "123"
> == "123"
>
> 'a & 'b are the "SAME" string! and refer to the same memory
> location. 'c has the same value on the surface but is a
> separate instance of a string! value and is stored at a
> separate memory location.
I think explaining the above in C is vastly more complex than
explaining it in terms REBOL has already established. You may
very well wreak havoc on the understanding people DO have of
the above by trying to explain it using C.
'A and 'B are both different words. They are NOT strings.
Both words refer to (have the value of) the same string. 'C
is also a different word than 'A and 'B. It refers to a
different value (a different string).
These particular notions of WORDS and VALUES are a distinct
aspect of REBOL and they are not an aspect of C. WORDS and
VALUES are within in the vocabulary of REBOL, but they are not
to be found in the vocabulary of C. C's typed variables are
an especially poor analogy to REBOL WORDS, for example please
describe the following in C:
word: 1
word: make object! [word: func [][print "I am a function"]]
word: word/word
word: 'word
I can easily explain the above in terms of WORDS and VALUES,
but I would find it very difficult to explain in terms of C's
typed variables and pointers. That's like explaining calculus
using Lincoln Logs.
REBOL is first class and EVERYTHING is data. This concept is
utterly absent from C. Please provide an example of how one
may understand the nature of REBOL's first class code/data
duality with C code.
> That is why this....
>
> >> insert b "abc"
> == "123"
> >> b
> == "abc123"
> >> a
> == "abc123"
> >> c
> == "123"
>
> The value of 'A & 'B both change but 'C remains unaltered. You can show this in 'C
( or some other language ) by use of pointers and references as Joel
> did.
..."or some other language".. hmmm.. what would be a good
language for describing REBOL... hmmm... maybe REBOL? It's
its own metalanguage, afterall! :-)
> Similarly....
>
> >> a: <abc>
> == <abc>
> >> parse a [b:]
> == false
> >> b
> == "123"
>
> How do you explain that unless you drop down to C or
> something else and show your any-string! or any-block!
> models with pointers to memory storage for the actual "data" values.
> In the above example both reference the "Same" string!
> data but 'a has the datatype! value tag! whilst 'b is
> a normal string! datatype!
Well, you might start by understanding that in REBOL there are
WORDS and WORDS can refer to VALUES. (Words are VALUES
themselves, by the way.) Once you have those concepts firmly
in hand, move onto understanding how PARSE treats set-words in
a rule.
Would you explain the movement of the knight in chess in terms
of the way you play checkers?
> Also what is wrong with helping your neighbour to paint
> his fence is you neighbour is your friend?
It depends on the informed consent of the fence painter, and
who claims credit for the fence being painted. :-)
-jeff