with-variable ( value key quot -- ) (original) (raw)

Vocabulary
namespaces

Inputs

value an object
key a variable, by convention a symbol
quot a quotation

Outputs
None

Word description
Calls the quotation in a new namespace where key is set to value.

Examples
The following two phrases are equivalent:

[ 3 x set foo ] with-scope

3 x [ foo ] with-variable

Definition

USING: hashtables kernel ;

IN: namespaces

: with-variable ( value key quot -- )
[ associate ] dip with-variables ; inline