Charles Childers


blog | parable | retro | ios apps | fountain pens


Parable

Parable is a small language, built over a compact byte coded virtual machine. The language uses a concatenative model with a strictly reverse polish notation, type awareness, and garbage collection.

The syntax draws from earlier work on Toka and Retro, making extensive use of anonymous, nestable functions (called quotations) for function definition and control structures. The language also depends heavily on prefixes to help the compiler decide how to handle tokens. (These are a lot like colors in ColorForth, but are represented as single characters rather than color or stylistic elements).

One other major difference from my earlier work is the memory model. Parable divides memory into distinct regions called slices. Memory accesses are done by referencing a slice and an offset. This differs from Retro and Toka which both used a single linear memory area for all code and data. The use of slices has allowed for some interesting things, including a garbage collector, and much simpler decompilation back to readable source code.

The core language does not provide a specified I/O model. This is intentional; I now work with a variety of platforms and languages, and enforcing the existence of a traditional console environment has proven to be a limiting factor. Parable frees me to implement custom I/O functionality on a per-application basis, through the use of custom byte code additions. I have written numerous interfaces, including a simple script interpreter, an interactive full screen REPL, a browser based interface, and an implementation for iOS. There is also a console script interpreter with support for file I/O, basic output and command line argument support.

Development

Apologue is a Parable IDE for iPad and iPhone.

Examples

'hello world'

# Average some values
[ 1 3 5 7 9 ] slice-length? [ 0 [ + ] reduce ] dip /