In Forth the names of the operations are not overloaded; so similar
operations on different types need different names; e.g.,
integers, and you have to use
f+ to add floating-point numbers.
The following prefixes are often used for related operations on
signed double-cell integer
unsigned double-cell integer
two cells (not-necessarily double-cell numbers)
mixed single-cell and double-cell operations
floating-point (note that in stack comments ‘f’ represents flags, and ‘r’ represents FP numbers; also, you need to include the exponent part in literal FP numbers, see Floating Point).
If there are no differences between the signed and the unsigned variant
+), there is only the prefix-less variant.
Forth does not perform type checking, neither at compile time, nor at run time. If you use the wrong operation, the data are interpreted incorrectly:
If you have only experience with type-checked languages until now, and have heard how important type-checking is, don’t panic! In my experience (and that of other Forthers), type errors in Forth code are usually easy to find (once you get used to it), the increased vigilance of the programmer tends to catch some harder errors in addition to most type errors, and you never have to work around the type system, so in most situations the lack of type-checking seems to be a win (projects to add type checking to Forth have not caught on).