Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Forth (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Compilation state and interpretation state ==== The word <code>:</code> (colon) parses a name as a parameter, creates a dictionary entry (a ''colon definition'') and enters compilation state. The interpreter continues to read space-delimited words from the user input device. If a word is found, the interpreter executes the ''compilation semantics'' associated with the word, instead of the ''interpretation semantics''. The default compilation semantics of a word are to append its interpretation semantics to the current definition.<ref name="compiler" /> The word <code>;</code> (semi-colon) finishes the current definition and returns to interpretation state. It is an example of a word whose compilation semantics differ from the default. The interpretation semantics of <code>;</code> (semi-colon), most control flow words, and several other words are undefined in {{Not a typo|ANS}} <!-- not a misspelling --> Forth, meaning that they must only be used inside of definitions and not on the interactive command line.<ref name="compiler" /> The interpreter state can be changed manually with the words <code><nowiki>[</nowiki></code> (left-bracket) and <code><nowiki>]</nowiki></code> (right-bracket) which enter interpretation state or compilation state, respectively. These words can be used with the word <code>LITERAL</code> to calculate a value during a compilation and to insert the calculated value into the current colon definition. <code>LITERAL</code> has the compilation semantics to take an object from the data stack and to append semantics to the current colon definition to place that object on the data stack. In {{Not a typo|ANS}} <!-- not a misspelling --> Forth, the current state of the interpreter can be read from the [[flag (programming)|flag]] <code>STATE</code> which contains the value true when in compilation state and false otherwise. This allows the implementation of so-called ''state-smart words'' with behavior that changes according to the current state of the interpreter.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)