[comp.lang.forth] Strongly typed Forth??

koopman@a.gp.cs.cmu.edu (Philip Koopman) (09/21/88)

A year or two ago, Hans Niewenhuser (I *know* I spelled it incorrectly!!)
gave an argument at the Rochester Forth Conference that Forth has the
potential to be a strongly typed language.  The argument for this is based
on the use of CREATE ... DOES> ...  (or whatever your dialect calls it).

In most implementations, the DOES> re-points the code field to the DOES> ...
clause code.  So, if you make each kind of variable with its own DOES>
field, then each kind of variable has a different CFA value.  The CFA
value then contains the type information.  A clever compiler (especially
an infix expression processor extension) can exploit this typing information
to do automatic type conversions.

For example:

: VARIABLE   CREATE    0   ,  DOES> ;
: DVARIABLE  CREATE  0.0  D,  DOES> ;

VARIABLE VA
VARIABLE VB

In this example, VA and VB will have different CFA values.

  Phil Koopman                koopman@maxwell.ece.cmu.edu   Arpanet
  5551 Beacon St.
  Pittsburgh, PA  15217    
PhD student at CMU and sometime consultant to Harris Semiconductor.