REBOL Programming/function

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

USAGE:[edit]

FUNCTION spec vars body 

DESCRIPTION:[edit]

Defines a user function with local words.

FUNCTION is a function value.

ARGUMENTS[edit]

  • 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]

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
]