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

[REBOL] intersting side-effect to dynamic word usage...

From: media:quazart at: 15-Nov-2001 9:57

Hello world, What I am about to point out might be common knowledge to some of you but in the hopes that this will be usefull to someone, I explain it anyways... Basically, there is a side-effect to using 'to-word and more specifically 'to-set-word... here is a little piece of code which illustrates this. I have added some comments in-line in the code so that I can explain just what happens as the program executes. I have used Romano's excelent anamonitor.r script to give visual feedback of exactly what happens... to run the code below, download his script (if its not already in your favorite downloads) and just change the path so that it can be loaded. Otherwise, just read the comments in the code, as these explain what happens if you do not wish to run the example. ------------ code follows ----------------- rebol [] ;----------- LOAD Romano's object/block browser do load %/your/path/to/romanos/anamonitor.r aaa-block: [] monitor system/words dynamic-word: ask "WHAT IS NEW WORD TO ADD? :" ;----------------- ; let's say we answered "aaa", we now append this string to our word-block ; append aaa-block to-set-word dynamic-word ;---------- AT THIS POINT IN EXECUTION, ; something funky happens... ; the set-word exists within the block which is now set as [aaa:] ; this is expected... ; ; BUT! ; ; a word is ALSO set inside the system/words block and is set to ; aaa ; ; I just thought I'd note this as it might interest some of you ; ; check it out: monitor system/words ; ; here I just set the value (WITHOUT USING the word's name in the code) ; set in system/words to-word form first aaa-block "MAMA!" print to-word form first aaa-block monitor system/words ask "" Anyways, this is just a quick trick I found out... the above also seems to stand if you use the to-word function .... which also seems to instantly add the word in system/words, even if you're inserting it in a block directly. -MAx