www.delorie.com/gnu/docs/gforth/gforth_110.html   search  
 
Buy GNU books!


Gforth Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.10 Interpretation and Compilation Semantics

The interpretation semantics of a (named) word are what the text interpreter does when it encounters the word in interpret state. It also appears in some other contexts, e.g., the execution token returned by ' word identifies the interpretation semantics of word (in other words, ' word execute is equivalent to interpret-state text interpretation of word).

The compilation semantics of a (named) word are what the text interpreter does when it encounters the word in compile state. It also appears in other contexts, e.g, POSTPONE word compiles(17) the compilation semantics of word.

The standard also talks about execution semantics. They are used only for defining the interpretation and compilation semantics of many words. By default, the interpretation semantics of a word are to execute its execution semantics, and the compilation semantics of a word are to compile, its execution semantics.(18)

Unnamed words (see section 5.9.6 Anonymous Definitions) cannot be encountered by the text interpreter, ticked, or postponed, so they have no interpretation or compilation semantics. Their behaviour is represented by their XT (see section 5.11 Tokens for Words), and we call it execution semantics, too.

You can change the semantics of the most-recently defined word:

doc-immediate doc-compile-only doc-restrict

By convention, words with non-default compilation semantics (e.g., immediate words) often have names surrounded with brackets (e.g., ['], see section 5.11.1 Execution token).

Note that ticking (') a compile-only word gives an error ("Interpreting a compile-only word").

5.10.1 Combined Words  


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003