REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 18-Feb-2009 Edit History  

REBOL 3 Concepts: Tour: Blocks

Pending Revision

This document was written for R2 and has yet to be revised for R3.

OLD DOCS

This section is obsolete and being replaced. It is kept only as a source for new content.

REBOL is composed by grouping values and words into blocks. Blocks are used for code, lists, arrays, tables, directories, associations, and other sequences.

A block is a type of series which is a collection of values organized in a specific order.

A block is enclosed in square brackets [ ]. Within a block, values and words can be organized in any order and can span any number of lines. The following examples illustrate the valid forms of blocks:

[white red green blue yellow orange black]

["Spielberg" "Back to the Future" 1:56:20 MCA]

[
    Ted    ted@gw2.dom   #213-555-1010
    Bill   billg@ms.dom  #315-555-1234
    Steve  jobs@apl.dom  #408-555-4321
]

[
    "Elton John"  6894  0:55:68
    "Celine Dion" 68861 0:61:35
    "Pink Floyd"  46001 0:50:12
]

Blocks are used for code as well as for data, as shown in the following examples:

loop 10 [print "hello"]

if time > 10:30 [send jim news]

sites: [
    http://www.rebol.com [save %reb.html data]
    http://www.cnn.com   [print data]
    ftp://www.amiga.com  [send cs@org.foo data]
]

foreach [site action] sites [
    data: read site
    do action
]

A script file itself also is a block. Although it does not include the brackets, the block is implied. For example, if the lines below were put in a script file:

red
green
blue
yellow

When the file is loaded, it will be a block that contains the words red, green, blue, and yellow. It is equivalent to writing:

[red green blue yellow]


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin