Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Function Context Query

From: rotenca:telvia:it at: 4-Dec-2001 23:51

Hi, Larry
> 1) load time > The word 'a' in the body block [a] of the function definition has been bound > to the global context before the function FUNC is executed, at this time it > will be associated with the value "hello".
Yes, but this is true for everything which is loaded. It depends only by load.
> 2) function definition time > After func has run, a local context has been created in which the word 'a' > has no value. It is unset. The body block is not evaluated at function > definiton time, but is bound to the new context.
This is like in use body or at the start of the body of an object:
>> probe make object! [x: unset? get/any 'a a: 2]
make object! [ x: true a: 2 ]
> 3) function application time > Only after g has been executed, is the word 'a' set to NONE. The local words > in the function only get values when the function is applied. If the values > are determined by the arguments or refinements, or by the use of SET or a > set-word in the body block; they assume that value, otherwise they are set > to NONE.
This is the "strange" (but useful) thing which happens in function body (and not in use or object body): at the start of the execution of function body all the context values are set to none or to the value of args (true for refinement!).
> Cheers > -Larry
--- Ciao Romano