Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [context] How to compose in a local context

From: Gary:Jones:usap:gov at: 22-Apr-2004 9:38

From: Ashley Tr=FCter Given the following:
>> b: 'a
== a
>> do has [a][set 'a 0]
== 0
>> a
** Script Error: a has no value ** Near: a
>> do has [a][do compose/deep [set [(b)] 0]]
== 0
>> a
== 0 How can I prevent 'compose from binding to the global context? **** Hi, Ashley, I'm not an expert on binding, but as you seem to be aware, it appears as though the order of evaluation has 'a being set to 0 in the global context by way of the 'do command *inside* the block. An alternative approach is to "compose" the full line: b: 'a do compose/deep [has [a][set (to-lit-word b) 0]] The actual lines I used in order to be sure that I had it right was: b: 'a do compose/deep [ c: has [a][ set (to-lit-word b) 0 print (b) ] ] such that:
>> do compose/deep [
[ c: has [a][ [ set (to-lit-word b) 0 [ print (b) [ ] [ ]
>> c
0
>> a
** Script Error: a has no value ** Near: a
>> b
== a
>>
Finally, if you want to get the function ready but not run it, then: b: 'a reduce compose/deep [ c: has [a][ set (to-lit-word b) 0 print (b) ] ] Hope that helps. --Scott Jones