[REBOL] Re: Words escaping from context! help needed!
From: antonr:lexicon at: 11-Feb-2005 23:52
The problem is that the words in variables is not
bound to your object.
When objects are made, the spec block is first scanned
for set-words. In your example, there are three set-words
in the spec block, [variables: data: executor:]
These are now the only words which can exist directly in the
object, and they are bound to the object.
Objects can't be arbitrarily expanded or shrunk; you can't add
or remove words. (This is a pity, but I believe it speeds
things up the way it is.)
Anyway, as sad as that sounds, there is a way of wrapping things
up safely in a context. Here is a possible solution:
my-ctx: context [
make-object-spec: func ["Prepare an object spec block from words and data."
result: copy 
repeat n length? words [append result reduce [to-set-word words/:n
executor: func [variables data program /local object][
object: context make-object-spec variables data
do bind/copy program in object 'self
my-ctx/executor [a b] [1 2] [print a + b]
;** Script Error: a has no value
;** Near: a
I should also like to know the reason why you