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

[REBOL] Re: Embedded Object and Scope yet again...

From: larry::ecotope::com at: 11-May-2001 17:26

Hi Joel
> IMHO, using DO or USE is a more general mechanism, as it actually > allows you to "embed" references wherever you wish, instead of being > limited to the global level as with SET. For example: >
I'm a little puzzled by your remark. SET is not limited to binding in the global context. Rather, the target word is simply searched for up through the context hierarchy. The first match determines the context where the binding occurs, in exactly the same fashion as the look-up for the value of a word. For example: a: none ob: context [ b: none em-ob: context [ c: none set 'a 52 set 'b 53 set 'c 54 ] ] After this code is run, we have:
>> a
== 52
>> ob/b
== 53
>> ob/em-ob/c
== 54 We could also have said set [a b c] [52 53 54] in the em-ob, with exactly the same results. One limitation of SET is that it will only take a WORD or BLOCK as argument, it will not accept a path. In that sense your DO construct is more general. It is perhaps worth noting that in reading thousands of lines of "internal" port, view, vid, and desktop code, I don't recall ever seeing USE used, perhaps because it was broken (exported refs generated a GC crash)for most of the last 2 years. Clearly, it is not really needed to create complex REBOL programs. -Larry