[REBOL] Re: [context] How to compose in a local context
From: g:santilli:tiscalinet:it at: 21-Apr-2004 16:35
Hi Ashley,
On Wednesday, April 21, 2004, 4:07:28 PM, you wrote:
>>> b: 'a
AT> == a
>>> do has [a][set 'a 0]
AT> == 0
>>> a
AT> ** Script Error: a has no value
AT> ** Near: a
>>> do has [a][do compose/deep [set [(b)] 0]]
AT> == 0
>>> a
AT> == 0
AT> How can I prevent 'compose from binding to the global context?
The binding of the body of a function is done at function creation
time. Also, COMPOSE just replaces the paren with its value after
evaluation, so in this case it just places the word A in place of
the paren there; that word! value happens to be bound to the
global context.
So you can either set B to a word that is already bound to the
context you want, like in:
>> do has [a][b: 'a do compose/deep [set [(b)] 0]]
or you can bind the entire block returned by COMPOSE to your local
context:
>> do has [a][do bind compose/deep [set [(b)] 0] 'a]
Regards,
Gabriele.
--
Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/