Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

A little bit of Rebol content

 [1/4] from: brianwisti::yahoo::com at: 26-Dec-2004 1:20


Hi all, Part of my learning experiences involve scribbling down notes and putting them on my website in hopes that they'll be useful to someone else. So here's my attempts at writing down my learning of Rebol: - http://coolnamehere.com/geekery/rebol/learn/part01.html - http://coolnamehere.com/geekery/rebol/datatypes.html Please take a look and let me know what you think! Kind Regards, Brian Wisti http://coolnamehere.com/

 [2/4] from: pwawood::mango::net::my at: 27-Dec-2004 22:19


Hi Brian 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
== integer! type? now == date!
>> type? /time
== refinement!
>> type? now/time
== time! 2. Rebol infers the datatype of a value from its format
>> type? 12.34.56.78
== tuple!
>> type? http://www.bbc.co.uk
== url! 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.
>> 1
== 1
>> now
== 27-Dec-2004/14:04:40+8:00
>> now/time
== 14:04:14
>> [big bigger biggest]
== [big bigger biggest] 4. In console mode, Rebol returns the last value it evaluated :
>> 1 2 3 4 5 6
== 6
>> now/time 5
== 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.
>> soup-of-the-day
== "minestrone" 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 the word.
>> type? soup-of-the-day
== string! 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
== word! A word is "connected" to value by using the set function :
>> set 'soup-of-the-day "minestrone"
== "minestrone" or its shorter form, known as a set-word:
>> soup-of-the-day: "oxtail"
== "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"
== "12345"
>> type? string
== string!
>> string: find string "a"
== none
>> type? string
== none! But you probably knew all of this already. Happy Reboling Peter

 [3/4] from: brianwisti::yahoo::com at: 27-Dec-2004 10:32


Hi Peter, Thanks for the extra information. No, I didn't know all this already :-) I'm pretty happy to see that the handling of variables and types is similar to other dynamic languages that are already lodged into my brain, especially Ruby. Means less for me to worry about :-) Kind Regards, Brian Wisti http://coolnamehere.com/ --- PeterWAWood <[pwawood--mango--net--my]> wrote:

 [4/4] from: antonr:lexicon at: 27-Dec-2004 14:17


Mmm.. Not bad at all. Loads fast and nice style here on Firefox. After a quick look the only thing I thought was a bit negative was: I thought I told you to stop bothering me, kid. Just seemed unnecessary, since your world-wide audience includes kids. Anton.