The result is not what I expect.  How do we account for this behavior. 

>> probe :a
"a"

I thought the output would be ""

Please explain this in more detail.



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Sunday, August 20, 2000 4:58 PM
To: [EMAIL PROTECTED]
Subject: [REBOL] problems with local vars??? Re:(8)


Hi,

no "Dialect" notion can help you with your problem. (My personal
preferences are, that Rebol functions aren't "Rebol dialect",
because I think that there is a difference between a Rebol code in
a block and a Rebol function, which has got more attributes, than
Rebol code - see my Rebol function model in Words, Bindings and
Contexts thread.) Back to your problem. The difference you see can
be visualised here:
>> probe :a
"a"

a: 0
b: :a
add :b 1
probe :a

The results show, that there are differences between integers and
strings in Rebol, Rebol strings are mutable (you can change them),
while integers are immutable (you cannot change them). More can be
found eg. in:
www.rebol.org/advanced/mutable.r  or in the Evaluation thread.


Regards
    Ladislav



> > 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.
>
>

Reply via email to