# Reverse Polish Scheme Reverse Polish Scheme (RPS) is a programming language for people who think continuations are too easy to understand. RPS is stack-based programming language vaguely based off of FORTH but really just Scheme in disguise. RPS only has jumps: in order to return from a procedure, you need to use `call/cc` to capture the current continuation and pass it to the procedure. ## Core Writing a number, a string, `#t`, `#f`, or `#nil` will push that literal value onto the stack. Strings are equivalent to Scheme symbols. `#nil` is the name of a value, NOT the symbol `"nil"`! A linked list is a 2-vector whose second pair is either `#nil` or another linked list. A procedure is a linked list whose first slot is unused and whose code starts in the second slot. * `n alloc`: Allocate a memory region of `n` pointers. * `{ ... }`: Reads all data up to the matching `{` as data. The data is stored as a linked list. * `v n ref`: Get the nth element of `v`. * `value n v set!`: Set the nth element of `v`. * `sr jump`: Jump to a procedure. * `conditional on-false on-true if`: If `conditional` is truthy, jump to `on-true`. Otherwise jump to `on-false`. * `proc keep-bot keep-top call/cc`: Jump to `proc` with the continuation pushed to the stack. The continuation object saves the last `keep-top` objects on the stack along with the bottom `keep-bot` values on the stack. If either is `#f`, then the entire stack is saved. When `m cc jump` is called (where `cc` is the object returned by `call/cc`), the `m` values currently on the stack are pushed to the top of `n` values saved by `cc`, and control returns to the next location after `call/cc`. * `dir? n dig`: When `dir?` is false, move the `n`th value relative to the top of the stack to the top of the stack. When `dir?` is true, move the `n`th value relative to the bottom of the stack to the top of the stack. * `dir? n bury`: When `dir?` is false, move the top value on the stack to the `n`th value relative to the top of the stack. When `dir?` is true, move the top of the stack to `n`th value relative to the bottom of the stack. * `dup`: Duplicate the top of the stack. This is a shallow copy. * `drop`: Drop the top of the stack. * `x y eqv?`: Compare two values on the top of the stack, returns a boolean. ## License DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2025 Peter McGoron Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. If you are concerned about the legalities of this license, then this software is not for you. Go back to Java.