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

[REBOL] Re: [Newbie]: Problems with lit-words

From: antonr::lexicon::net at: 28-Oct-2005 15:02

Hi Silvia, Your expression: set a "" is evaluated like this, (using parens to indicate current focus): (set) a "" ; I am a word SET, my value is a function, so let's do it. ; This function expects two arguments, so let's get them first: set (a) "" ; I am a word A, my value is a word B, so let's return B. set a ("") ; I am a string, my value is myself, so let's return that. ; Now SET has all the arguments it needs, so it is done. So the above is as if you typed: set 'b "" which is evaluated like this: (set) 'b "" set ('b) "" ; lit-word 'B evaluates to the word B. set 'b ("") So the overall problem, I think, is that you are expecting the SET function to take its WORD argument literally. What actually happens is that the rebol interpreter reduces A before SET gets to even look at it. If you did: print a you might think it is PRINT which reduces A to its value, but, in fact, A is reduced by the interpreter *before* it is passed to PRINT. The way I think about literal words, words and values is like this. lit-word -> word -> value where "->" means "reduces to", and automatic evaluation usually means moving one step to the right is very easy. So, in your case: 'b (lit-word) -> b (word) -> "" (value) and, you have also set A's value to the word B: a (word) -> b (word) -> "" (value) Anton.