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

[REBOL] Re: Create words dynamically

From: greggirwin::mindspring::com at: 5-Mar-2006 13:29

Hi Jeff, Welcome to REBOL! JM> I'm pretty new to REBOL (and loving it so far), but couldn't you just coerce JM> the strings to words using TO-WORD? JM> foreach symbol in words [ JM> w: to-word symbol JM> ; do something with w JM> ]
>> words: [ "phhtmcl" "phhocml" ]
== ["phhtmcl" "phhocml"]
>> foreach symbol words [w: to-word symbol]
== phhocml What we've done here is set the value of the word W to reference a word! value created from the symbol, but not created new words from those symbols.
>> w
== phhocml
>> phhocml
** Script Error: phhocml has no value ** Near: phhocml Given a word, it's easy to use SET to set it to an initial value. This will create global words the way I think you expected.
>> foreach symbol words [set to-word symbol none]
== none
>> phhocml
== none Words, binding, series, and evaluation behavior aren't always obvious, especially if you're coming from other languages, so don't be afraid to ask questions if things don't work as expected. Happy REBOLing! -- Gregg