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

[REBOL] Words, Bindings and Contexts. (1)

From: lmecir::geocities::com at: 23-Jul-2000 19:01

Hi Rebols, Mark Dickson wrote: 1. What contexts are? 2. Why are they important? 3. How are they determined i.e global or local ? 4. How, where & when are "new" context created ? 5. What is the lifespan of new context? 6. Why is it useful to know about this stuff ? 7. What productive use can be made of this ? Here are my answers: (feel free to suggest a better terminology or wording) What are Rebol Words? **************************** Word! is a very important Rebol datatype. A word can be used as a value eg.: probe 'a , or: equal? 'a 'b etc. What are Rebol Bindings? ****************************** The most important property of Rebol Words is the ability to contain any Rebol Values, so you can "store" a Rebol Value in a Word like: a: 12 set 'a 12 set/any 'a 12 and get the "stored" value back as: :a get 'a get/any 'a
>From the printable form of a Word like mold 'a, mold 'b, etc., you
cannot decide, if and what value is stored in it. Even equal words can store different values, as can be seen here: ; create a block Blk containing a word 'a blk: copy [a] a: 12 ; now append another word to Blk b: make object! [append blk 'a a: 13] probe blk ; test if blk contains equal words equal? first blk second blk equal? get first blk get second blk What is the reason behind such a "mystery"? The answer is simple: *Words have Bindings* and the first Word in Blk has a different Binding, than the second. The former sentence looks logical, but it doesn't make a good sense yet, because I didn't say, what are Rebol Bindings. Let's put a sense into it: *Rebol Binding definition:* Every Rebol Word has attributes allowing it to "contain" Rebol Values. The set of that attributes I am calling the Word's Binding. When do Words have equal Bindings? A few observations: a) different (ie. Not-equal) Words have different Bindings b) equal words may have either equal or different Bindings (see above) c) the same Words have equal Bindings d) Words, that have equal Bindings are the same Illustration of d): same? first blk (bind second blk first blk) to be continued...