[REBOL] Re: Context - code included- 2nd version
From: rotenca:telvia:it at: 13-Sep-2001 0:44
> I don't know if the discussion didn't start to be boring, but here are my
> reactions:
Up to now, i have learned many things and cleared many of my ideas on Rebol.
So i should say: boring but useful to me :-)
> I bound the SPECIAL ('foo) to a USE context and stored the result to BOUND.
> Nevertheless, the SPECIAL ('foo) still doesn't look changed. It still looks
> like a Special Word. Are you trying to convince me that it shouldn't,
> because it has been bound to the This Context?
That message is ambiguos. Natural language is not a formal language.
That message should be changed because some people mis-interpret it :-)
> Basic fact # 1: My definition of the Rebol Context notion is the only
> definition available.
Sorry, it is an incorrect definition. You can use your definition, but it is
not a definition of Rebol Contexts, is the definition of Mecir Contexts.
It is absolutly clear in Core Doc that a word in itself has no value. A word
with no value (=Special Word) is a value and can be used as a Symbol.
When a word has been linked to a value, it can be used also as Variable.
Values are stored in block, and collected and linked to words in Context.
Value are NOT stored in word (as you say). It is clear that Contexts are
collections of Variables, not collections of Words. Symbols are alfanumeric
indexes to get values from Contexts:
first system/words
returns the alphanumeric indexes (Symbols) accepted by the global object to
connect known values to known words.
In:
>> in rebol/words first to-block "system"
== system
The word without value "system" (SpecialWord) is used as a symbol, i.e. like a
value. It is like to use the value 3 to index a block. When you say that a
Rebol Context is a collections of words, it is like you said that the block
x: ["a" "b" "c"]
collects
the integer 3 because you can get "c" with the expressions:
x/3
This is all. A Mecir Context is a collection of words. A Rebol Context is a
collection of Variables. They can convive, only if they are not confused each
other (like you make).
Now some evidence and comments from RT documentation:
1)
Message ID: not-defined
A word used was not defined within any context.
Message:
[:arg1
is not defined in this context"]"
Tell me how you can explain the word "any". When a word is in a context, only
that context can give a definition to the word, so why to speak of "any"
others contexts?
2) "A variable refers to a specific value only within a defined context," p.
2-9
So when it doesn't "refers to a specific value" (=get fails = SpecialWord) it
is not "within a defined context"
3) "the context of words in a string is not known." 3-11
4) "The scope of a variable is determined when its context is defined."
Ergo: context of a word can be undefined.
5) "Binds meaning to words in a block. That is, it gives
words a context in which they can be interpreted.
This allows blocks to be exchanged between different
contexts, which permits their words to be understood."
6) "Words can be reused. The meaning of a word is dependent on its context, so
words
can be reused in different contexts."
7) "Words are the symbols used by REBOL. A word may or may not be a variable,
depending on how it is used."
8)"A variable refers to a specific value only within a defined context, such
as a block,
a function, or an entire program. Outside that context the variable can refer
to some
other value or to no value at all."
9) "Words are used in two ways: as symbols or as variables."
A word is a variable if it has a value, and it has a value if is defined in a
context. Outside a context the word can have a value if is defined in another
context, or it can have no value and in this case is "not defined within any
context".
So my functions could become (restricting the use of word "symbol"):
variable?: binded? ...
symbol?: not binded? ...
and words: variables + symbols. It is also incorrect to speak of local words
and global words, you must speak of
local-variables (object-variables + block-variables - i.e. use,
func)
global-variables
> > Indeed, your definition of collection (11.) depends from the notion of
> > bindings:
>
> Not at all, it only uses a Rebol function the implementation of which I
> wrote. When I did it I didn't need any notion of bindings. I needed only to
> write something in Rebol.
So i could say that the two class of words Loaded?/Not Loaded? are two
Contexts because they divide all the words in collections and i can write the
function which make the division? Too easy.
> Cheers
> Ladislav
> >
---
Ciao
Romano