rebol_styleComing from other languages you may have some habits but Rebol has its own style to do things the shortest way. Rebol’s shortcuts may not be obvious for the absolute beginner so you may need some time to get accustomed but you will gain tremendous productivity by making the effort when you want to do advanced coding like runtime-code execution (see last example).

Just install Rebol and type the few examples below in Rebol Console.

First block of code is the beginner’s way, second block is the expert’s way:

Instead of this:


fullname: rejoin ["John" " " "Doe"]

Write this:


fullname: form ["John"  "Doe"]

Instead of this:


fullname: rejoin ["It is " " " now/time " " "O'clock"]

Write this:


fullname: reform ["It is" now/time "O'clock"]

Instead of:


myfile: rejoin [%dir/ "read.txt"]

Write this:


myfile: join %dir/ "read.txt"

Instead of:


person: "john"
code: {print ["Hello" }
append code rejoin [{"} person {"}]
append code "]"
do code

Write this:


person: "john"
str-code: mold [print ["Hello" Person]]
code: load str-code
do code

Instead of this (see “Rebol Mini-Text Database” or “Rebol Mini-Text Database - Part 2: binding to a Visual Form“):


db: []; create the block
append db to-block mold record-1
append db to-block mold record-2

Write this:


db: []; create the block
append/only db record-1
append/only db record-2

Instead of


>> b: [field "field1" tab field "field2"]
== [field "field1" tab field "field2"]
>> head remove back tail (remove mold b)
== {field "field1" tab field "field2"}
>>

Write this (thanks Sunanda):


b: [field "field1" tab field "field2"]
mold/only b
== {field "field1" tab field "field2"}

Bookmark and Share

Recent Articles