spill is a tiny stack-based programming language that borrows ideas from Forth and Factor. The interpreter is written in Python. A previous version of spill was implemented in the MoonScript dialect of Lua.
Start the REPL with ./spill
.
Say hello:
spill> "Hello, spill!" print
Hello, spill!
Evaluate simple expressions:
spill> 1 2 3 + / .
0.2
Define and use functions:
spill> : ++ 1 + ;
spill> 42 ++ .
43
Apply quotations with combinators:
spill> 1 2 3 [ ++ ] dip
spill> show
[1, 3, 3]
Inspect generated "bytecode":
spill> [ 3 0 > if "yes" else "no" then . ] spill show
[push, 3, push, 0, >, branch?, 11, push, yes, branch, 13, push, no, .]
Check src/prelude.spill
for more examples.
Stuff that could be added to make the language more useful:
- Stack effect comments
- Better control constructs
- Proper support for strings and sequences
- Map/dictionary data type
- Vocabularies of words
- My history with Forth & stack machines
- A simple stack-oriented language
- Forth: The programming language that writes itself