4 ms·
Immediate words in Forth are somewhat analogous to macros, and therefore can do this kind of stuff if need be - not evaluating something, or evaluating somethin
by int_19h 7y ago
Immediate words in Forth are somewhat analogous to macros, and therefore can do this kind of stuff if need be - not evaluating something, or evaluating something several times. Take a look at a sample implementation of IF/ELSE/THEN and DO/LOOP:
https://github.com/nornagon/jonesforth/blob/4f853252f715132e7716cbd44e5306cefb6a6fec/jonesforth.f#L118 https://github.com/nornagon/jonesforth/blob/4f853252f715132e...
Forth also has anonymous words (:NONAME), so you can dynamically define a computation and pass it around on the stack, and later execute it. I don't think there's any way to clean them up, though (no GC).