Demystifying Vectored Execution
From the modern-day terminology perspective, vectored execution in Forth is neither vectored nor execution, yet it exists, and it’s a unique feature in Forth. In the core of vectored execution lies an execution token (previously promised).
An execution token (xt) is a fragment of compiled Forth code—a compiled word. Forth enters compile mode when you type a colon : and leaves when you type a semicolon ;. Everything between : and ;, except the word name, is converted into a token. Then the token is combined with the name and stored in the dictionary. In this previously presented example, INVERT IF DROP -1 THEN becomes an execution token, and FIX becomes its dictionary name:
| | : FIX ( n flag -- n1 ) INVERT ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access