Imagine the following REBOL code:
foo: context [bar: 3]
I now have a context foo in which 'bar is defined. How can I dynamically inject a new word into this context? Is it possible?
I’ve tried:
set/any in foo 'baz 3
But that doesn’t work because the expression in foo 'baz fails because there is no word 'baz defined in the foo context.
I should add that I realize one way to do this is as follows:
foo-prototype: [bar: 3] foo: context foo-prototype foo: context head append foo-prototype [baz: 3]
But what if you don’t have access to foo‘s prototype block?
You can achieve the same by using the existing object as a prototype to create a new object.