Define a primitive data type: Difference between revisions

Content added Content deleted
Line 548: Line 548:
{{ works with|ANS/ISO Forth|}}
{{ works with|ANS/ISO Forth|}}
Standard Forth does not type data but it does "type" words that act on data. True to the low level nature of Forth the responsibility to select the correct action word for specific data is given to the programmer. That being said there are some simple ways to add the requested mechanism to your Forth system.
Standard Forth does not type data but it does "type" words that act on data. True to the low level nature of Forth the responsibility to select the correct action word for specific data is given to the programmer. That being said there are some simple ways to add the requested mechanism to your Forth system.

It is worth noting that Forth's penchant for simplicity means we do not need to write new math operators since each operator is atomic and takes arguments from the stack and returns the result to the stack. Therefore we get the desired functionality by only changing the assignment operation.


=== Method 1: Safe Integer Store operators===
=== Method 1: Safe Integer Store operators===