This is a Python implementation from the spec. It is almost certainly not exactly feature-compatible with the official implementation.
#
as a comment start symbol, with a newline ending the comment, and this implementation also supports it.Although this implementation supports #
for comments, the spec-compliant way of writing a comment is
Comment -> Out_"Comment text goes here"
The computational model is basically that of Minsky, as described here. A Minsky RM program can be converted into an Alchemist program very simply: a state q: a + r
becomes a rule Q -> A + R
; and a state q: a - s t
becomes two rules: Q A -> S
and Q 0A -> T
. Optimisations can then be applied to reduce chains of rules to single rules. The representation of both states and registers as atoms nicely exposes the equivalence of code and data.
The real departure from the Minsky RM is the addition of non-determinism.
However, from a programming praxis perspective there is another nice feature of Alchemist. The state is not constrained to be represented by one atom: we can use a tuple of atoms, and this allows (non-recursive) subroutines. If the sequence of states between q
and r
is identical to the sequence of states between s
and t
then we can represent q
as Q SUB
, s
as S SUB
; implement the sequence between states SUB
and RET
; and then define rules Q + RET -> R
and S + RET -> T
.