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

[REBOL] context of a function Re:(4)

From: fsievert:uos at: 22-Aug-2000 21:10

On Mon, 21 Aug 2000 [rebol--techscribe--com] wrote:
> Hi Frank, > > I think you are speaking about three distinct, albeit related tasks: > > 1. Determining which words are bound to the context of a function. > 2. Binding words that are bound in the context of a function to that context. > 3. Determining which values these words are associated with.
Thats absolutely right.
> Re 1: > You can easily determine which words are bound to the context of a function > by retrieving the first or third block of a function.
No, thats not possible. Example:
>> f: func [a] [a] >> make object! [a: none insert second :f 'a]
There is no way to find out, which of the a's is the one, which is bound to functions context now.
> With exception of /local all of these words are bound to the function's > context, as soon as the function is constructed.
Local (as a word) is, too.
> Re 2: > You can easily bind the words in the function's first or third block to the > function's context: > > >> bind fblock first second :f > == [a ref b]
Not possible here: f: func [a] [] No word example -> no way to say bind. That s why we need in for functions.
> Re 3: > You can now easily determine which values the words are associated with in > the function's context:
Same problem as above.
> Conclusion: > This approach only works if there is at least one word that is local to the > function's context available at a known index in the function's body. In > this example it was the word "a" in the first position in the function's body.
You could overwrite func, but I think, REBOL should support this. Its the same as in objects. To serialize functions like shown above (the one with the two a's), you need a way to find out, which of the a's are bound to functions body and which not. I would like to use "in" for that, which would be the same sollution as for objects. Greetings, Frank