[REBOL] Re: [subject: error and trial]
From: holger:rebol at: 5-Mar-2002 12:31
On Tue, Mar 05, 2002 at 02:58:27PM -0500, alan parman wrote:
> Thanks, Holger!
>
> Do I have the following essentially correct?
>
> >> probe end!
> ** Script Error: end! has no value
> ** Where: halt-view
> ** Near: probe end! ;rebol has not "seen" this word in the global context
No, REBOL has seen the word, right after you typed it in, REBOL loaded
your "script" and bound it into the global block. That's why undefined?
would return false. You get the error because the word does not have
a value in the global context (which is where the word was bound into).
> >> probe first first rebol/words
> end! ;rebol has seen this word before, in 'rebol/words
> == end!
Yes.
> >> undefined? first first rebol/words
> == true ;'end! is not in the global context
Actually 'end! does appear in the global context:
>> found? find first rebol/words 'end!
== true
True is returned in your example because words which appear in the word table
of a context are always unbound.
> >> undefined? in rebol/words 'end!
> == false ;'end! is in the context of 'rebol/words
Yes.
> >> value? first first rebol/words
> == false ;'end! does not have a value in the global context
No, that does not matter in this example. See
>> a: 1
>> value? first find first rebol/words 'a
== false
The reason why you are getting a 'false response is because you
are getting the word from the word table of a context. Those
words are always unbound, and therefore do not have a value.
Whether a word with the same spelling, bound into that context,
would have a value or not does not matter in the example.
> >> value? in rebol/words 'end!
> == false ;'end! does not have a value in the context of 'rebol/words
Yes. Note that the context of rebol/words IS the global context.
There is a difference between using
1. first find first some-context 'some-word (or variations of it)
and
2. in some-context 'some-word
1
returns a word directly taken from the context's word table. Those words
are always unbound, regardless of whether that same word, if bound into the
context, has a value or not. This means value? on such a word always returns
false?, undefined? always returns true.
2
creates a word that has the same spelling as the word you supply, but bound
into the context (or none if the word does not appear in the context). Assuming
the word does appear, value? on such a word tells you whether the word has a
value in that context, undefined? always returns false.
--
Holger Kruse
[kruse--nordicglobal--com]