[REBOL] Re: Context - code included- 2nd version
From: holger:rebol at: 10-Sep-2001 17:57
On Mon, Sep 10, 2001 at 08:47:33PM +0200, Ladislav Mecir wrote:
> I am trying to comply with the official documentation if possible:
> special: first to block! "a"
> set special 1
> ** Script Error: a is not defined in this context
> ** Where: halt-view
> ** Near: set special 1
> This is how I can interpret it:
> 1) the word 'a stored in 'special is "in a context"
> 2) it is "in a context" where it "isn't defined"
> 3) I call that context the Special Context
That is not necessary. Don't invent something if you don't have
to :). Occam's Razor...
You just misunderstood the error message. The "is not defined" refers
to the word not existing (in this context), not to the word not having
a value in it. In other words: the word is unbound.
There is no "Special Context" of the kind you describe in REBOL. A word
is either unbound or it is bound into a context. A word can only have a
value if it is bound. Most of the time words are bound automatically.
There are some exceptions, e.g. words in blocks created by to-block "string".
The only context that is (somewhat) unusual, e.g. in that it can
dynamically expand, is the global context, exposed at the REBOL layer
through system/words. The global context behaves just like a regular context
in most ways though, e.g. it only contains words which have been bound
to it, i.e. it does not necessarily contain ALL words:
>> find first system/words 'abcd
(The word 'abcd on the command line was bound into the global context by the
interpreter after parsing the input.)
>> find first system/words first to-block "abce"
(The word 'abce was never bound into the global context.)