Rebol Programming/function

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

USAGE:[edit | edit source]

FUNCTION spec vars body 

DESCRIPTION:[edit | edit source]

Defines a user function with local words.

FUNCTION is a function value.

ARGUMENTS[edit | edit source]

  • spec -- Optional help info followed by arg words (and optional type and string) (Type: block)
  • vars -- List of words that are local to the function (Type: block)
  • body -- The body block of the function (Type: block)

SOURCE CODE[edit | edit source]

function: func [
    "Defines a user function with local words." 
    spec [block!] {Optional help info followed by arg words (and optional type and string)} 
    vars [block!] "List of words that are local to the function" 
    body [block!] "The body block of the function"
][
    make function! head insert insert tail copy spec /local vars body
]