|REBOL 3 Docs||Guide||Concepts||Functions||Datatypes||Errors|
|TOC < Back Next >||Updated: 6-Feb-2009 Edit History|
Functions can define other functions. The sub-functions can be global, local, or returned as a result, depending on their purpose.
For example, to create a global function from within a function, assign it to a global variable:
make-timer: func [code] [ timer: func [time] code ] make-timer [wait time] timer 5
To make a local function, assign it to a local variable:
do-timer: func [code delay /local timer] [ timer: func [time] code timer delay timer delay ] do-timer [wait time] 5
The timer function only exists during the period when the do-timer function is being evaluated.
To return a function as a result:
make-timer: func [code] [ func [time] code ] timer: make-timer [wait time] timer 5
|TOC < Back Next >||REBOL.com - WIP Wiki||Feedback Admin|