[REBOL] problems with local vars??? Re:(5)
From: galtbarber:mailandnews at: 18-Aug-2000 15:03
To Andrew:
why do you say that rebol functions
are a kind of rebol dialect?
I thought they were more of a built-in type function!
There are some special things that happen in a function
that are all about binding params and locals,
but I would be surprised if functions worked internally
like the dialect that is in parse or view.
If it works that way, it's a sheer revelation
to me. In fact, how could you define a dialect
without referring to other functions?
Is that a chicken and egg kind of thing?
To Everybody:
in the examples given in this thread,
there is none showing this obvious one using /local with func:
somefunc: func [
n [integer!]
/local tmp
][
tmp: n * n
;;; snipped rest of code ...
]
I believe that internally 'function will just
end up calling 'func and passing the block of
locals as /local. If you make yourself a function f
with 'function and then look at first :f, second :f
and third :f, you will see that in first :f there
is the param list with the locals defined with /local.
I think this change appeared with Rebol2.
-Galt
p.s. although Rebol may be "interpreted",
the body and params and etc. have been fully
load
-ed and that means they are like typed
tokens and bound words that are ready to roll.
It's not like a lot of simple interpreters which are converting
straight from source as just a string of characters
for each and every line.
when the function definition is executed
that baby creates the function! value and
assigns it to the function's name word,
and that value sure isnt just a string! of code.
so that makes sense and the interpreter can run
pretty fast. I am sure that it is the same
with Logo, Lisp, Scheme, etc... I think the
series type is also something that helps make
Rebol fast. I don't recall seeing its like
in those other cousins of Rebol.
-Galt