Next: Factoring Tutorial, Previous: Stack-Effect Comments Tutorial, Up: Tutorial
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
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 oeration, 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).