a small, stack-based calculator/programming language inspired by forth.
i wanted to learn a little bit about the Io language. also, i wanted to practice programming in general.
install the Io interpreter from the linked site. then, run
io main.io. if you want to check out one of the demo programs, say for instance
io main.io program.txt instead.
running the program will put you into a REPL. you can enter words (whitespace-separated strings) here, and they will be executed in order. here are some of the things you can do:
|any number||push the number onto the stack.|
||duplicate the stack top item.|
||swap the two top stack items.|
||pop the stack.|
||exit the REPL.|
||empty the stack.|
|any word prefixed by
||push the word without executing it (this is stackable).|
||pop the stack, and execute the popped value as a word.|
you can read the source code for more info on what builtin words are available, or the example programs to get an idea of how programming this calculator works.
there's also the
examples/ directory, which will contain small, specific examples. note that, while comments aren't actually supported, these examples might pretend that comments are supported. if so, they'll indicate single-line comments by starting the line with a
- expose the
dowordinternal function to the calculator. this would let programs modify its behaviour, for instance to make it possible to declare functions without quoting everything that you don't want to execute at function-construction-time.