This is the reference implementation/vm for Clac++, which is a simple stack-based postfix (reverse polish notation) calculator/programming language. It supports programmer-defined functions, control flow and unrestricted recursion.
$ cat print2.clac
: dup 1 pick ;
: print2 dup print dup print ;
25 10 * 5 / print2
quit
$ ./clac++ print2.clac
50
50It is inspired by and (aims to be) backward compatible with the "Clac" language from Carnegie Mellon University's 15-122 programming class.
Additionally, Clac++ allows for arbitrary syscalls, and reads/writes to arbitrary memory addresses.
The current (draft) Clac++26 standard requires that implementations define the size of integer values on the Clac Stack.
Implementations must provide a builtin function width_native, which must push the size of a Clac Value (in bits) to the stack. The native width on this implementation is 64 bits, to allow for representing pointers on a 64-bit system.