Rebol Programming/Internals

From Wikibooks, open books for an open world
< Rebol Programming
Jump to navigation Jump to search

Rebol Internals[edit | edit source]

The System Object[edit | edit source]

The System object is a very large object that contains most of the mezzanine code in Rebol, that is VID, the network protocols and system information about the Rebol product you are running.

Native Functions[edit | edit source]

Native functions are functions that are hardwired into the kernel of Rebol. They can be considered low-level functions, that are designed for speed. A wide range of native functions exist.

You can reveal a native function in the console like this:

>> source insert
insert: native [
    {Inserts a value into a series and returns the series after the insert.} 
    series [series! port! bitset!] "Series at point to insert" 
    value [any-type!] "The value to insert" 
    /part "Limits to a given length or position." 
    range [number! series! port! pair!] 
    /only "Inserts a series as a series." 
    /dup "Duplicates the insert a specified number of times." 
    count [number! pair!]

The source code cannot be seen since the function is compiled into the Rebol interpreter kernel.

Mezzanine Functions[edit | edit source]

Mezzanine functions are functions that are built on top of either native or other mezzanine functions. This means you can change them or build more functions on top of existing ones. Rebol has in all of its products many mezzanine functions built in.

They can be considered higher level functions, that are designed to provide ease of use, when coding your Rebol programs. The internet protocols in Rebol such as HTTP or POP3 are built as mezzanine functions.

When designing your own programs, you can build your own functions that blend in with the existing mezzanine functions, for example if you wish to extend Rebol with a new internet protocol.

Mezzanine functions are also special in that you can see the source code for them on the console like this:

>> source append
append: func [
    {Appends a value to the tail of a series and returns the series head.} 
    series [series! port!] 
    /only "Appends a block value as a block"
] [
    head either only [
        insert/only tail series :value
    ] [
        insert tail series :value