Search code examples
rebolred-lang

REBOL methods in Red


Disclaimer: What I'm trying to achieve is something like what was discussed here - Evaluating a "variable variable".

I want to create variables in red dynamically with identifiers based on some parsed data. Examples from post above mention Rebol (R2?) rejoin and to-word methods, but I didn't succeed calling them in Red however, getting Script error: rejoin has no value all the time.

Are such methods present in Red or what are the alternatives? Should I add some module into my script?


Solution

  • In Rebol, both rejoin and to-word are both shortcuts for more elemental functions. In Red (as of version 0.6.0) both of these functions are available:

    >> to word! "foo"
    == foo
    >> to word! append "foo" "bar"
    == foobar
    

    It's likely better to copy the first string before appending, but this should be enough to create dynamic words.