angerangel edited this page Jan 3, 2013 · 1 revision

USAGE

   FUNCT spec body /with object /extern words

DESCRIPTION

Defines a function with all set-words as locals.

FUNCT is a function value.

ARGUMENTS

  • spec -- Help string (opt) followed by arg words (and opt type and string) (block!)
  • body -- The body block of the function (block!)

REFINEMENTS

  • /with -- Define or use a persistent object (self)
    • object -- The object or spec (object! block! map!)
  • /extern
    • words -- These words are not local (block!)

#SOURCE

funct: make function! [  [
    "Defines a function with all set-words as locals."
    spec [block!] {Help string (opt) followed by arg words (and opt type and string)}
    body [block!] "The body block of the function"
    /with "Define or use a persistent object (self)"
    object [object! block! map!] "The object or spec"
    /extern words [block!] "These words are not local"
][
    unless find spec: copy/deep spec /local [append spec [
            /local
        ] ]
    body: copy/deep body
    append spec collect-words/deep/set/ignore body either with [
        unless object? object [object: make object! object]
        bind body object
        append append append copy spec 'self words-of object words
    ] [
        either extern [append copy spec words] [spec]
    ]
    make function! reduce [spec body]
] ]
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.