You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Classic (standard) Forth systems are remarkably consistent in using techniques invented 40 years ago. For instance, the classic interpreter still executes command lines word by word. I wonder why. Of course, it works and everyone is used to it. But it does not have to be that way.
TclForth compiles the command line and then executes the compiled line. If the command line is compiled it can handle immediate words. You can enter lines like this
1 begin dup 10 < if "*" else "&" then . 1+ dup 20 > until drop
TclForth always compiles. Interpret is compile and execute.
If you need to calculate a value while compiling a definition, enclose the calculation in square brackets as usual. The code inside the brackets is compiled, then executed by ']' .
There are just two moments in the interpreter when code is executed: end-of-command-line and ']'. Thus, STATE is obsolete, it is not tested. And if there is no STATE to test, the immediate bit also makes little sense. TclForth replaces immediate by Compiler.
Immediate words are now Compiler words that execute native Tcl code. Example:
Compiler if
appendcode "if \[pop\] \{\n"
Code and Colon words compile a call to their execution semantics. Compiler words perform their compilation semantics.
The text was updated successfully, but these errors were encountered:
wejgaard
changed the title
Always compiling.
The command line accepts immediate words
Feb 19, 2015
wejgaard
changed the title
The command line accepts immediate words
Always compiling. Forth without STATE.
Feb 19, 2015
(Discussed in comp.lang.forth)
Classic (standard) Forth systems are remarkably consistent in using techniques invented 40 years ago. For instance, the classic interpreter still executes command lines word by word. I wonder why. Of course, it works and everyone is used to it. But it does not have to be that way.
TclForth compiles the command line and then executes the compiled line. If the command line is compiled it can handle immediate words. You can enter lines like this
TclForth always compiles. Interpret is compile and execute.
If you need to calculate a value while compiling a definition, enclose the calculation in square brackets as usual. The code inside the brackets is compiled, then executed by ']' .
There are just two moments in the interpreter when code is executed: end-of-command-line and ']'. Thus, STATE is obsolete, it is not tested. And if there is no STATE to test, the immediate bit also makes little sense. TclForth replaces immediate by Compiler.
Immediate words are now Compiler words that execute native Tcl code. Example:
Code and Colon words compile a call to their execution semantics. Compiler words perform their compilation semantics.
The text was updated successfully, but these errors were encountered: