![]() |
You. Forth. Simplicity. |
reload node | edit | recent changes | front page
Another important language element is deferred sequences of code. Some words, specifically the parsing words, like is and devector, can not be directly used in a definition. To get around this, a common approach is to use a string and evaluate it:
: foo ['] clear s" is bar " eval ;
RetroForth supports this with the { ... } structure. Code between { and } is interpreted when the word is run. So the above example could be done as:
: foo ['] clear { is bar } ;
This does have one significant limitation: you can not nest deferred sequences. Other than that, it should be quite useful in a variety of situations. You may also use these in .self or .macro class words since the evaluation process does not change the compiler state.