[REBOL] problems with local vars??? Re:(7)
From: bhandley:zip:au at: 19-Aug-2000 12:41
> second :f is different. It returns a "live" block of code (the body) with
> the contained words bound to the local frame of the function f. This
block
> of code can be modified with and extended (with append etc. using 'bind if
> necessary) after the function is created.
> It seems clear that the
> interpreter executes the function by 'do-ing this body block.
The original reason I originally questioned the relationship between
functions and dialects in this thread was due to this "'do-ing the body
block" concept. To make the question specific define a function f like
this:
>> f: func[/local x][x: {} append x "a" print x]
My question then is, how are the first two values (x: {}) of the body block
treated when the interpreter executes the function? In terms of purely
executing the block, logically it seems, the first two values could be
considered redundant, correct?
A related issue (maybe), I don't know if it is been asked before.
If I now use f, I get:
>> f
a
>> f
aa
Compare this with another function g and its results:
>> g: func[/local x][x: 0 x: add x 1 print x]
>> g
1
>> g
1
Are these results related to the execution of a function or the
interpretation of datatypes?
Any enlightenment please?
Brett.