[REBOL] Re: A little bit of Rebol content
From: pwawood::mango::net::my at: 27-Dec-2004 22:19
A couple of points relating to datatypes and variables that aren't clear
from your notes. This is my understanding as a fellow Rebol learner. I'm
sure that the many wise Rebolers will chip in and correct my mistakes.
1. Everything is a value in Rebol. Values have datatypes.
>> type? 1
>> type? /time
>> type? now/time
2. Rebol infers the datatype of a value from its format
>> type? 188.8.131.52
>> type? http://www.bbc.co.uk
3. Rebol simply evaluates the values in the order it is presented with them,
normally a line at a time (though blocks enclosed in  can extend over a
line). Each datatype has it's own evaluation rules.
>> [big bigger biggest]
== [big bigger biggest]
4. In console mode, Rebol returns the last value it evaluated :
>> 1 2 3 4 5 6
>> now/time 5
5. There are no variables in Rebol. Rebol has the datatype word. A word
stores the "address" of a value. When Rebol evaluates a word, it actually
evaluates the value "pointed" to by the word.
Even before passing a word to the type? function which returns the datatype
of a value, Rebol evaluates the word as the underlying value "pointed" to by
>> type? soup-of-the-day
Sometimes you don't want Rebol to evaluate a word but want to refer to the
word itself. This is done by putting a ' in front of the word. This is
referred to as a literal word or lit-word in Rebol.
>> type? 'soup-of-the-day
A word is "connected" to value by using the set function :
>> set 'soup-of-the-day "minestrone"
or its shorter form, known as a set-word:
>> soup-of-the-day: "oxtail"
Words can be pointed at any type of value including other words, blocks,
functions, ports, schemes and so on.
One of the Rebol learners mistakes that I often make is to expect a word to
always point to a value of a certain type. In most programming languages the
datatype is associated with the variable (eg int i), but in Rebol the
datatype is associated with the value not the word that points to it.
Here is an example :
>> string: "12345"
>> type? string
>> string: find string "a"
>> type? string
But you probably knew all of this already.