[REBOL] Words, Bindings and Contexts. (2)
From: lmecir:geocities at: 23-Jul-2000 20:47
Rebol Contexts
******************
Before introducing other properties of Bindings, I will try to
introduce Contexts.
Rebol Contexts are existing data, so we are not free to use any
definition of them. The "proof":
some Contexts are directly available:
Global Context is available as Rebol/Words
Objects
Some Contexts are not directly available, but because there is a
GC fault, they can be garbage-collected, which proves, that they
really existed (I cannot imagine collection of a non-existent
thing).
Here are some functions enabling us to access contexts not
directly available:
global: func [
{create a Global Context Word equal to the given Word}
word [word!]
] [
; this is just one of many possibilities, how to do it
make word word
]
global?: func [
{find out, if the given Word is a Global Context Word}
word [word!]
] [
same? word global word
]
; this function can help us explore the Contexts, that aren't
directly available
same-context?: func [
{find out, if the given Words are the Words of the same
Context}
word1 [word!]
word2 [word!]
/local word3
] [
if all [global? word1 global? word2] [return true]
if any [global? word1 global? word2] [return false]
if global? word3: bind global word1 word2 [return false]
same? word1 word3
]
to be continued...