Forth

Forth Command Line and Programming Language.

Compliance

Compliance mainly means levels of compliance with the Forth standards.
I have to admit that implementing everything that is in the standard was not my goal when I wrote the Embeddable Forth Command Interpreter. There is no reason to be different just for the sake of being different, on the other hand I tried to focus on what is practically useful when a Forth command line is added to a large C program, not what someone on a committee deemed as “common use” that needs to be carved in stone put into the standard document.

As such the Embeddable Forth Command Interpreter is not a fully compliant system, but it should run a fairly large number of standard programs without a problem.

Let’s go through the word sets in the standard.

CORE Words

Most words should be supported with the notable exception of FM/MOD and SM/REM. If double number arithmetics is disabled some other CORE words become unavailable, mainly related to numeric formatting such as #. Currently the Embeddable Forth Command Interpreter uses 32 bit cells, they usually are wide enough for most calculation needs. If in the future it becomes necessary to use 64 bit wide cells on some system that would make double numbers 128 bits wide — increasingly diminishing return on having to support arithmetic operations on those. For the same reason mixed with arithmetic operations such as */ and */MOD are also unavailable if double precision arithmetics is not supported.

CORE EXTENSION Words

Support for core extension words was treated as more optional than support for CORE words even though that might not have been the intention of the creators of the standard. As such lots of CORE EXTENSION words are missing and might never be added to the system (unless they to prove to be necessary in some situation). There is no C”, VALUE or TO — I specifically have an intense dislike towards the latter. A VALUE TO pair could be easily added using CREATE DOES>.

BLOCK and BLOCK EXTENSION words

The BLOCK and BLOCK EXTENSION word sets are not supported at all in the Embeddable Forth Command Interpreter. I do not have anything specifically against them, but on none of the systems I have worked on have I ever needed them, so I saw no particular reason to actually have blocks.

The variable BLK does exist in the implementation and the system handles it in the assumption that blocks might need to be added at one point, but there are no immediate plans.

DOUBLE NUMBER and DOUBLE NUMBER EXTENSION Words

These are supported unless specifically disabled at compile time with the notable exception of M*/ which requires a triple cell intermediate result and I just did not go into the trouble of implementing it when I have never actually used it. Should a real need arise for it support can be added in the future.

EXCEPTION Words

CATCH and THROW are emphatically supported — I would almost go as far that these should be mandatory in all but the most trivial systems. The changed semantics for the two aborts is also supported. The behavior is slightly different from the standard in the sense that an empty exception frame causes a return to the calling C program. Commands such as QUIT do have a catch in them. This difference in behavior should be mostly unnoticeable for the kind of programs that are intended to be run on the system.

FACILITY Words

As it turns out all of them are supported providing that the appropriate features are compiled in and the runtime environment supports them. The distinction between KEY and EKEY is rather artificial though.

FILE ACCESS and FILE ACCESS EXTENSION Words

These are supported if compiled in with the exception of FILE-STATUS whose definition is utterly useless in the standard (it returns something implementation defined and there is no way that a program only using things that are defined in the standard can do anything useful with it).

FLOATING POINT and FLOATING POINT EXTENSION Words

Floating point is not supported by the Embeddable Forth Command Interpreter. I do not have any immediate plans to support any floating point operations for the simple reason that I never needed them in Forth.

LOCALS and LOCALS EXTENSION Words

Not supported! Mostly personal dislike. I can see that they might make Forth more acceptable to people who actually cannot program in Forth but I really do not see any other use for them. If some great need would arise perhaps I would add them.

MEMORY ALLOCATION Words

Supported providing they are compiled in.

PROGRAMMING-TOOL Words

This seems to be a ‘miscellaneous’ category — everything that is not in one of the other word sets was just dumped here.

There is no assembler in the Embeddable Forth Command Interpreter but there are various tool from this wordset.
DUMP ? SEE WORDS .S AHEAD BYE CS-PICK CS-ROLL and STATE are supported. Also [IF] [ELSE] [THEN].

The words SYNONYM used to define another name for a word and the words [DEFINED] and [UNDEFINED] are not present in the ’94 Forth standard but the proposed new Forth-200x standard lists them as TOOLS EXT words — they are present in the Embeddable Forth Command Interpreter since they do satisfy a valid need — I don’t understand how that was overlooked in the ’94 standard.

STRING Words

Some words supported incidentally. I did not try to add string operations specifically, mostly because I never needed them in similar projects that the Embeddable Forth Command Interpreter is aimed for.

The word COMPARE is present because it is needed for the implementation of [ELSE]. CMOVE and CMOVE> looked like useful operation to move bytes around and SLITERAL was needed for S”.

SEARCH ORDER and SEARCH ORDER EXTENSION Words

Supported. I would prefer hierarchical name spaces but I was told I was wrong when I raised the issue some 20 years ago….

Last updated: April 20, 2014