.s- Show the stack+,-,*,mod- Math operators/mod- performs both / and mod
dropand2drop- drop a stack item (once / twice)dup- duplicate a stack itemrot- rotate the stack
s" file.fs" included- Loads file.fs into memorygforth code.fs tests.fs -e bye- Load a file and exit if something goes wrong (instead of the command line)
(and\- Comments. Comments are significant in Forth, so keep a space between them.
By convention the comment after the name of a definition describes the stack effect: The part in front of the '--' describes the state of the stack before the execution of
the definition, i.e., the parameters that are passed into the colon definition; the part behind the '--' is the state of the stack after the execution of the definition,
i.e., the results of the definition. The stack comment only shows the top stack items that the definition accesses and/or changes.
You should put a correct stack effect on every definition, even if it is just ( -- ). You should also add some descriptive comment to more complicated words (I usually do
this in the lines following :). If you don't do this, your code becomes unreadable (because you have to work through every definition before you can understand any).
: squared ( n -- n^2 ) \ The parenthesis are just a convention to explain the function.
dup * ;see- 'decompiles' a word to see source.