REBOL

From Wikipedia, the free encyclopedia

Jump to: navigation, search
REBOL
Paradigm data exchange language and multi-paradigm: dialected, functional, prototype-based, structured and imperative programming language
Appeared in 1997
Designed by Carl Sassenrath
Developer REBOL Technologies
Latest release Core 2.7.6, View 2.7.6/ March, 2008, R3 alpha, March, 2009
Typing discipline dynamic, strong
Major implementations REBOL/Core 2.7.6, REBOL/View 2.7.6, REBOL/SDK 2.7.6
Dialects data exchange dialect, do dialect, parse dialect, function specification dialect, object specification dialect, visual interface dialect (VID), script specification dialect, draw dialect
Influenced by Self, Forth, Lisp, Logo
OS cross-platform
Website http://www.rebol.com

REBOL is a cross-platform[n 1] data exchange language and a multi-paradigm programming language originally designed by Carl Sassenrath for network communications and distributed computing. The name REBOL pronounced ['reb-ol] stands for "Relative Expression Based Object Language".

REBOL introduces the concept of dialecting: small, optimized, domain-specific languages for code and data[1][2], which is also the most notable property of the language according to its designer

Although it can be used for programming, writing functions, and performing processes, its greatest strength is the ability to easily create domain-specific languages or dialects.

[3]

REBOL has been used to program Internet applications (both client- and server-side), database applications, utilities and multimedia applications[1][4][5].

Contents

[edit] History

First released in 1997, REBOL was designed over a 20 year period by Carl Sassenrath, the architect and primary developer of AmigaOS, based on his study of denotational semantics and using concepts from the Lisp, Forth, Logo, and Self programming languages.

REBOL/Command, which added strong encryption and ODBC access, was released in September 2000.

REBOL/View was released in April 2001, adding graphical capabilities on top of the core language.

REBOL/IOS, an extensible collaboration environment built with REBOL was released in August 2001.

REBOL/SDK, providing a choice of kernels to bind against, as well as a preprocessor, was released in December 2002.

REBOL 3, the newest version of the REBOL interpreter, is currently in development. Alpha versions are being released publicly since January 2008.

[edit] Dialects

REBOL dialects are micro-languages optimized for a specific purpose. Dialects can be used to define business rules, graphical user interfaces or sequences of screens during the installation of a program. Users can define their own dialects, reusing any existing REBOL word and giving it a specific meaning in that dialect[5]. Dialects are interpreted by functions processing REBOL blocks in a specific way[n 2].

An example of REBOL's dialecting abilities can be seen with the word return. In the data exchange dialect return is just a word not having any specific meaning. In the do dialect, return is a global variable referring to a native function passing back a function result value[6]. In the visual interface dialect (VID), return is a keyword causing the layout engine to simulate a carriage return, moving the "rendering pen" down to the beginning of the next line[2].

REBOL interpreter with graphical capabilities has to understand and interpret a bunch of dialects to accomplish its task. The table below lists the most important ones in order of significance

Dialect name Interpreted by Purpose
Data exchange dialect represents data and metadata; common platform for REBOL dialects
Do dialect do function programming
Parse dialect parse function pattern matching; parsing expression grammar compatible language
Function specification dialect make function function definition; functional programming
Object specification dialect make function object definition/inheritance[n 3]; prototype-based programming
Visual interface dialect (VID)
or
RebGUI
layout function
or
display function
specifies graphical user interface
Draw dialect view function defines graphical elements (lines, polygons,etc.)
Script specification dialect do function script definition

[edit] Syntax

REBOL syntax is free-form, not requiring specific positioning. However, indentation is recommended to better convey the structure of the text to human readers.

Syntactic properties of different dialects may differ. The common platform for all REBOL dialects is the data exchange dialect; other dialects are usually derived from it. In addition to being the common platform for all dialects, the data exchange dialect is directly used to represent data and metadata, populate data structures, send data over Internet, and save them in data storage.

Differing from C or other programming languages the data exchange dialect does not consist of declarations, statements, expressions or keywords. A valid data exchange dialect text stream is a tree data structure consisting of blocks[n 4] (the root block is implicit, subblocks are delimited by square brackets), parens[n 5] (delimited by round brackets), strings[n 6] (delimited by double quotes or curly brackets suitable for multi-line strings), url's, e-mail addresses, files, paths or other composite values.

Blocks as well as parens may contain other composite values (a block may contain subblocks, parens, strings, ...) or scalar values like words[n 7], set-words (words suffixed by the colon), get-words (words prefixed by the colon), lit-words (words prefixed by the apostrophe), numbers, money, characters[n 6], etc., separated by whitespace.

Comments may appear following the semicolon until the end of the line. Multi-line comments or comments not ignored by the lexical parser can be written using "ordinary" datatypes like multi-line strings[6].

[edit] Semantics

Blocks containing domain-specific language can be submitted as arguments to specific evaluator functions.

[edit] do

The most frequently used evaluator is the do function. It is used by default to interpret the text inputted to the interpreter console.

The do dialect interpreted by the do function, is an expression-oriented sublanguage of the data exchange dialect. The main semantic unit of the language is expression. As opposed to imperative programming languages descending from ALGOL, the do dialect has neither keywords, nor statements.

Words are used as case-insensitive variables. The result, i.e. the evaluation of a word is returned, when a word is encountered by the do function. The set-word form of a word can be used for assignment. While not having statements, assignment, together with functions with side-effects can be used for imperative programming[6].

Subblocks of the root block are not interpreted by the do function, unless submitted as arguments to evaluating function. This property is used to define data blocks and for structured programming by submitting blocks as arguments to control functions like if, either, loop, etc[1].

A specific problem worth noting is, that blocks, assigned to variables, are not copied. Instead, a reference is provided. To make a copy, the block has to be passed to the copy function[6].

The do function normally follows a prefix style of evaluation, where a function processes the arguments that follow it. However, infix evaluation using infix operators exists too. Infix evaluation takes precedence over the prefix evaluation. For example,

abs -2 + 3

returns 1, since the infix addition takes precedence over the computation of the absolute value. When evaluating infix expressions, the order of evaluation is left to right, no operator takes precedence over another. For example,

2 + 3 * 4

returns 20, while an evaluation giving precedence to multiplication would yield 14. All operators have prefix versions. Do usually evaluates arguments before passing them to a function. So, the below expression:

print read http://en.wikipedia.org/wiki/REBOL

first reads http://en.wikipedia.org/wiki/REBOL and then passes the result to the print function. Parentheses can be used to change the order of evaluation. Using prefix notation the usage of parentheses in expressions can be avoided[n 8].

The simple precedence rules are both an advantage

  • no need to "consult" precedence tables when writing expressions
  • no need to rewrite precedence tables when a new operator is defined
  • expressions can be easily transliterated from infix to prefix notation and vice versa

as well as a disadvantage[1]

  • users accustomed to more conventional precedence rules may easily make a mistake

[edit] parse

The parse function is preferably used to analyse and interpret dialects. It does so by matching parse expressions at run time.

Parse expressions are written in the parse dialect, which, like the do dialect, is an expression-oriented sublanguage of the data exchange dialect. The parse dialect is compatible with the parsing expression grammar (PEG)[n 9]. Unlike the do dialect, the parse dialect uses keywords representing operators and the most important nonterminals, infix parsing operators don't have prefix equivalents and use precedence rules (sequence has higher precedence than choice).

Actions can be included to be taken during the parsing process as well and the parse function can be used to process blocks or strings[n 9]. At the string parsing level parse has to handle the "low level" parsing, taking into account characters and delimiters. Block parsing is higher level, handling the scanning at the level of REBOL values[1].

[edit] Implementations

The major REBOL interpreter is a non-free software[7] available in several editions (/Core, /View, /Command, /SDK and /IOS). Parts of the interpreter are open source, though. Example: the REBOL desktop is an open source part of the REBOL/View interpreter linking the REBOL community on the Internet. Both REBOL/Core and REBOL/View have been made available for producing distributable commercial applications at no charge[7]. The runtime environment is currently stored in a single executable file. REBOL/Core, the console edition, is about 300kB and REBOL/View, the graphical user interface edition, is about 650kB in size. REBOL/View provides platform-independent graphics and sound access, and comes with its own windowing toolkit and extensible set of styles (UI widgets). Extended editions, such as REBOL/Command or REBOL/SDK require a paid license; they add features like ODBC data access, and the option to create standalone executable files.

The following free software alternatives exist:

  • The RebGUI, an alternative to VID
  • The Orca interpreter

[edit] See also

[edit] Notes

  1. ^ [1] lists 34 computing platforms, the website lists 43 computing platforms
  2. ^ strings can be processed too, that is called string parsing
  3. ^ the script header object is defined using this dialect
  4. ^ unlike ALGOL blocks, REBOL blocks are composite values similar to quoted s-expressions in Lisp
  5. ^ parens are like blocks, just available for different purposes
  6. ^ a b unlike C, REBOL uses caret notation for unprintable characters
  7. ^ special characters are allowed in words, so a+b is a word unlike a + b, which is a sequence of three words separated by spaces
  8. ^ see the Polish notation article
  9. ^ a b a transliteration of a PEG example parsing strings as arithmetic expressions
    Digit: charset [#"0" - #"9"]
    Value: [some Digit | "(" Expr ")"]
    Product: [Value any [["*" | "/"] Value]]
    Sum: [Product any [["+" | "-"] Product]]
    Expr: Sum
    parse/all "12+13" Expr
    

[edit] References

  1. ^ a b c d e f Roberts, Ralph (2000). REBOL for Dummies. Hungry Minds. ISBN: 0764507451.
  2. ^ a b Auverlot, Olivier (2001). Rebol Programmation. Eyrolles. ISBN10 : 2-212-11017-0.
  3. ^ Sassenrath, Carl (2000). The REBOL scripting language. Dr. Dobb's Journal.
  4. ^ Auverlot, Olivier (2007). Rebol - Guide du programmeur.
  5. ^ a b In English: Auverlot, Olivier, Wood, Peter W.A. (2008). Rebol - A programmer's guide.
  6. ^ a b c d Goldman, E., Blanton, J. (2000). REBOL: The Official Guide. McGraw-Hill Osborne Media. ISBN-10 : 007212279X.
  7. ^ a b Rebol Technologies. License.

[edit] External links

Personal tools