[REBOL] Re: Confused about "word" forms
From: lmecir:volny:cz at: 2-Dec-2010 16:55
Duke]] - hi, your questions deserve good answers, and I hope you find my
notes below at least a bit helpful.
First of all, the term "form" is confusing to me. Would someone give
me an appropriate synonym.
Duke]] - if I understood you well, you did not want a "synonym" for
, rather you wanted to have a proper notion to refer to different
word types. In my opinion, the proper notion is either "datatype", or
I understand that a Rebol "word" is not a variable bound to a datatype
as in other programming languages. It is merely the "name" of a
container which can hold any Rebol datatype; which itself has the
Duke]] - this is not something you should worry much about. Words are
REBOL values of their own right, but they *can* be used as variables, to
refer to other REBOL values, also.
Assuming the Rebol word "age", if I want to have the name of the
container returned to me, I would use the syntax (form) 'age. Correct?
Where does the "lit-word" datatype come in? I don't get the
Duke]] - hmm, this may be quite hard to explain, so, let me introduce
the QUOTE function to you. This function takes any argument (in R3)
without allowing the DO function (or some of other common evaluators) to
evaluate it. Thus, from the QUOTE function we get exactly what we give.
>> type? quote age
>> quote age
So, to obtain the word age you mentioned above, we can use the word and
pass it to the QUOTE function.
That is not the only way, how to obtain the word age, though, there is
yet another way:
>> type? 'age
This is what you may encounter more frequently, but, in fact, the
processing is more complicated, than when using the QUOTE function,
since, when we examine:
>> type? quote 'age
>> quote 'age
we see, that 'age is actually not a word, it is a lit-word! Why, then,
the expression 'age yields a word, not a lit-word? The reson is, that
every REBOL value is processed (evaluated) somehow by the DO function,
unless such an evaluation is prohibited by using e.g. the QUOTE function.
And, the evaluation of a lit-word is done so, that the said lit-word is
processed, yielding its corresponding word.
If I want to have assign something to the "age" container, I would
is the ":" the "set-word!" datatype.
Duke]] - no, not at all, the age: value is a set-word, as can be seen
>> type? quote age:
>> quote age:
And, this set-word, when processed by the DO function, causes the age
variable to refer to the integer value 35, which also becomes the result
of the expression.
If I want the "contents" of age, I would use:
:age and have 35 returned to me. is the prefixed ":" the "get-word!"
Duke]] - I refer you to the above explanation, this is just an
I'm getting all balled up with the terminology - how is an "action" -
like "get the contents of the word called "age", a datatype?
]] - the :age REBOL value has a datatype. The "action" you mention takes
effect only when the DO function (or some other similar function)
processes the value.
Also, what's the difference between using:
SET age 45
Duke]] - this time, for the expressions to have a similar effect, you
need to write:
age: 45 ; i.e. you have this right
set 'age 45 ; since 'age is processed becoming age before being passed
; or, alternatively:
set quote age 45