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.

Arguments:

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

body [block!] - Block to evaluate

See also:

Description

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
]
900
print total
1234

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 > REBOL.com - WIP Wiki Feedback Admin