Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
\ ============================================================================== \ \ RubyFORTH -- Copyright (C) 2007-8, Marc Simpson (GPL). \ \ Implement backtick, similar to ANS Forth's 'postpone'. \ \ ============================================================================== needs tools/whereis.fs compiler : ` peek-word in-compiler? if [compile] [compile] else [compile] compile then ; ( Backtick behaves like [compile] for words in COMPILER and like compile for ) ( words in FORTH. Its semantics are confusing at first sight, and its usage is ) ( not recommended. It is supplied for users of the ANS Forth 'postpone' word. ) ( ) ( Usage is as follows. Imagine that we want to create two new words, 'ddup' ) ( and 'start'. 'ddup' will compile '2dup', 'start' will compile 'begin'. ) ( In the absence of backtick, these are implemented like so: ) ( ) ( compiler ) ( : ddup compile 2dup ; ) ( : start [compile] begin ; ) ( ) ( With backtick, we can write the following: ) ( ) ( compiler ) ( : ddup ` 2dup ; ) ( : start ` begin ; ) ( ) ( Whichever scheme we choose, we can now say: ) ( ) ( forth ) ( : foo ddup ... ; ) ( : bar start ... ; )