[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always compiling. Forth without STATE. #2

Open
wejgaard opened this issue Feb 19, 2015 · 0 comments
Open

Always compiling. Forth without STATE. #2

wejgaard opened this issue Feb 19, 2015 · 0 comments

Comments

@wejgaard
Copy link
Owner

(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

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.

@wejgaard wejgaard changed the title Always compiling. The command line accepts immediate words Feb 19, 2015
@wejgaard wejgaard changed the title The command line accepts immediate words Always compiling. Forth without STATE. Feb 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant