FORTH

1. <language> An interactive extensible language using postfix syntax and a data stack, developed by Charles H. Moore in the 1960s.

Forth programs are structured as lists of "words" - FORTH's term which encompasses language keywords, primitives and user-defined procedures. A word is any string of characters except space. Words are read one at a time from the input stream and either executed immediately ("interpretive execution") or compiled as part of the definition of a new word.

The sequential nature of list execution and the implicit use of the data stack (numbers appearing in the lists are pushed to the stack as they are encountered) imply postfix syntax. Although postfix notation is initially difficult, practiced users find it simple and efficient.

Words appearing in executable lists may be either "primitives" (simple assembly language operations) or names of previously compiled procedures. A procedure definition is introduced by ":" and ended with ";" and is compiled as it is read.

Most Forth dialects include the source language structures BEGIN-AGAIN, BEGIN-WHILE-REPEAT, BEGIN-UNTIL, DO-LOOP, and IF-ELSE-THEN, and others can be added by the user. These are "compiling structures" which may only occur in a procedure definition.

Forth primitives consist of processor instructions assembled from assembly language contained between "CODE" and "C;" or "ENDCODE". Correct coding of primitives requires detailed knowledge of the relevant system internals.

Once assembled, primitives are used exactly like other words. A significant difference in behaviour can arise, however, from the fact that primitives end with a jump to "NEXT", the entry point of some code called the sequencer, whereas non-primitives end with the address of the "EXIT" primitive. The EXIT code includes the scheduler in some multi-tasking systems so a process can be descheduled after executing a non-primitive, but not after a primitive.

Forth implementations differ widely. Implementation techniques include threaded code, dedicated Forth processors, macros at various levels, or interpreters written in another language such as C. Some implementations provide real-time response, user-defined data structures, multitasking, floating-point arithmetic, and/or virtual memory.

FORTH tries to eliminate the distinction between operating system calls and the language. Commands relating to I/O, file systems and virtual memory are part of the same language as the words for arithmetic, memory access, loops, IF statements, and the user's application.

Many Forth systems provide user-declared "vocabularies" which allow the same word to have different meanings in different contexts. Within one vocabulary, re-defining a word causes the previous definition to be hidden from the interpreter (and therefore the compiler), but not from previous definitions.

FORTH was first used to guide the telescope at NRAO, Kitt Peak. Moore considered it to be a fourth-generation language but his operating system wouldn't let him use six letters in a program name, so FOURTH became FORTH.

Versions include fig-FORTH, FORTH 79 and FORTH 83. An draft-proposal ANSI standard Forth (dpANS-Forth) is proposed.

FORTH Interest Group, Box 1105, San Carlos CA 94070.

See also 51forth, F68K, cforth, E-Forth, TILE Forth.

[Leo Brodie, "Starting Forth"].

[Leo Brodie, "Thinking Forth"].

[Jack Woehr, "Forth, the New Model"].

[R.G. Loeliger, "Threaded Interpretive Languages"].

2. FOundation for Research and Technology - Hellas.

A small Greek software and research company associated with the Institute of Computer Science,

Address: Science and Technology Park of Crete, Vassilika Vouton, P.O.Box 1385 GR 711 10 Heraklion, Crete, Greece.

Telephone: +30 (81) 39 16 00, Fax: +30 (81) 39 16 01.

(22 Sep 1996)