TRANSLATING
REBOL expressions must be "translated" (as with 'do or 'load) before
all other activity. Barring erors, translating takes in text and
produces one or more entities. Translating a series involves:
* translating the values of the series (a potentially recursive
process for block values),
* allocating a sequence of sufficient size to contain the values,
* placing the values into the sequece, in order, and initializing
the end of the sequence based on the number of values placed, and
* initializing a series entity with a reference to that sequence
and an initial current position of 1.
The resulting series entity is the translation of the supplied text.
The translation of the REBOL expression:
[10 "1234" 11]
could be described by the picture (not REBOL notation!):
{{block! 1 *}}
|
V
<<10 * 12>>
|
V
{{string! 1 *}}
|
V
<<#"1" #"2" #"3" #"4">>
An entity is depicted as
{{ datatype! entity entity ... }}
a sequence is depicted as
<< element element ... >>
and references are depicted as arrows originating at asterisks.
The end position of a sequence is not diagrammed (the reader can
count the elements in all the examples given).
SET
A word (variable) can be "set" to any REBOL value. This simply
means that the word is associated with the value in a way that
allows it to be retrieved as needed. The effect of evaluating
the REBOL expression:
a: "1234"
may be diagrammed as:
a -> {{string! 1 *}}
|
V
<<#"1" #"2" #"3" #"4">>
GET
Evaluating a word begins with getting a reference to its associated
value. Some types of values, such as functions, require additional
activity (not discussed here) to complete evaluation.
The effect of evaluating the REBOL expression(s):
a: "1234"
b: a
may be diagrammed as:
a -> {{string! 1 *}}
^ |
| V
b ---+ <<#"1" #"2" #"3" #"4">>
The value of a is the same as the value of b because there is no
REBOL expression whose evaluation distinguishes them. Asking REBOL
to take any action with a and b should produce identical results.
>> a: "1234"
== "1234"
>> b: a
== "1234"
>> a
== "1234"
>> b
== "1234"
>> same? a b
== true
(continued in essay/3)