import styles from "./Tutorial.module.css" const Tutorial = () => ( <>
In the core of every SLAM program, there is an implied, global stack of strongly and dynamically typed values. A SLAM program consists of a sequence of words that when evaluated, can consume and produce values from/to the stack. New words can be defined with the define builtin word.
Just like in Forth, good SLAM words are short and succinct in their definition. Words should not leave extra values on the stack to avoid issues later on.
Phrases, roughly equal to Lisp's quoted S-expressions, are a sequence of words that are not immediately evaluated when encountered, but instead put on the stack for later manipulation. Phrases can be used to implement strings or heterogenous list structures. Phrases are also the core of conditional expressions, where branches of code are only evaluated when a condition is met.
Some useful SLAM words include:
+
Consume two numerical values and push their sum to the stack.
dup
Duplicate the top value of the stack.
.
Consume one value and print its string representation to the output.
cond
Consume three values (phrase2, phrase1, bool) from the stack. If bool is true, evaluate phrase1, otherwise evaluate phrase2.
See the examples above for more!
> ) export default Tutorial