REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 3-Aug-2010 Edit History  

REBOL 3 Functions: use

use  vars  body

Defines words local to a block.


vars [block! word!] - Local word(s) to the block

body [block!] - Block to evaluate

See also:


The first block contains a list of words which will be local to the second block. The second block will be evaluated and its results returned from the USE.

total: 1234
nums: [123 321 456]
use [total] [
    total: 0
    foreach n nums [total: total + n]
    print total
print total

Note: The USE function modifies the context (bindings) of the code block (as if BIND was used on it). This can lead to problems for recursive functions. To use the USE function recusively, you will need to COPY/deep the code block first:

words: [a]
body: [print a * b]
use words copy/deep body

  TOC < Back Next > - WIP Wiki Feedback Admin