[REBOL] generalities of addresses and values... Re:
From: larry:ecotope at: 9-Oct-2000 19:46
Well, there are a lot of issues raised by your questions. I am sure you will
get a number of responses. I will limit myself to a couple of quick
In many ways REBOL is closely related to the Scheme language.
1) In the Scheme community, pass-by-value means the arguments to a function
are evaluated by the interpreter before the function is called. This is true
of REBOL as well.
2) In Scheme, all (well almost all) values are (at least conceptually)
pointers (references). So an arg may be evaluated, but the value is a
pointer. REBOL is similar, but more complicated.
In Rebol, if a function has a string or block argument, the argument is
evaluated before the function is called. But strings and blocks evaluate to
themselves. In the case of blocks, the words within the block and
recursively in all nested blocks are added to the symbol global table by the
interpreter before the function is called, but no further processing is
done. The block is then assigned to the local word defined in the function
spec which is in the symbol table local to the function.
But what is really passed into the function and assigned to the local arg
word is a pointer to the string or block.
Here is a short example which illustrates this behavior.
>> s: "abcdef"
>> f: func [x][remove x]
>> f s
>> b: [1 2 3]
== [1 2 3]
>> f b
== [2 3]
== [2 3]
>> x ;x is a word local to the function f
** Script Error: x has no value.
** Where: x
Notice that modifying the block or string referenced by the local variable
x, also changes the original global value. To prevent that you would have to
use COPY to create a new copy either in the function call or within the
----- Original Message -----
Sent: Monday, October 09, 2000 11:55 AM
Subject: [REBOL] generalities of addresses and values...
> I'm a bit confused on how references work in Rebol. I wish there was a
chapter in the rebol core manual dedicated on this alone. Perhaps someone
could comment the general way addresses and values work in Rebol.