[REBOL] Words, Bindings and Contexts. (6)
From: lmecir:geocities at: 24-Jul-2000 19:55
In the previous sections I answered some questions regarding
Contexts.
The lifetime Contexts:
*************************
The Global Context should last forever, Local Context have
indefinite extent, which should mean, that if there were no GC
bugs, they should last as long, as they are accessible.
Now something on Bindings:
Bindings revealed:
**********************
I think, that I succeeded to demonstrate, that every Rebol Word
has got a Context attribute. The next attribute everybody is
familiar with, is its Mold attribute. It is simply the value that
can be obtained by:
mold 'word
The Context and Mold attributes are normally enough to
characterize a Rebol Word. A special case can be discussed:
Aliases. As a toy I present a function able to find out, if two
given words are aliases of each other:
aliases?: func [
{find out, if word1 and word2 are aliases}
word1 [word!]
word2 [word!]
] [
all [
; aliases are equal in Rebol
equal? word1 word2
; but have different Mold attributes
not equal? mold word1 mold word2
]
]
Aliases are not currently considered by Rebol as the same Words.
(Because their Mold attributes differ?)
Observation concerning Rebol Words is as follows:
Two Words are the same, if their Context attributes are the same
and their Mold attributes are equal.
(This would be true probably for all Contexts, but we haven't got
the means to check the case of Special Contexts and Dangerous
Contexts.)
Example illustrating, that the same value and equality of Words
doesn't mean the same Binding:
blk: copy [a]
a: 11
b: make object! [append blk 'a a: 11]
print [
mold blk
":"
mold reduce blk
]
print [
"Do the first and the second element above have the same
Binding?"
same-context? first blk second blk
]
What I didn't discuss, is the case of recursive functions in
Rebol, but I hope, that somebody finds even the present text
helpful. (If any of the questions at the beginning remains
unclear, feel free to ask.)
Ladislav