While State is a low level language that compiles directly to machine code, Church has features common to many high level languages (and some uncommon ones):
- A block-indented syntax (similar to Python or Haskell)
syntax new [(&rest args) (let ((class-name (second (first args))) (key-args (loop for (_key k v) in (cdr args) collect `(:symbol ,k) collect v))) `(:let (((:var "o") (:inline state::state-make-object (:symbol ,class-name) ,@key-args))) (:begin (:apply "init" (:var "o")) (:var "o"))))]
- A class system
- Dynamic dispatch (dispatch depends on all the arguments of a function, also known as multiple-dispatch)
- Pattern matching syntax like Erlang or Prolog (yet to be implemented)
- A high level ‘loop’ control structure
bar list1 list2 loop for x in list1 for y in list2 when x do (print x) when y do (print y) collect y
At the moment I have a fairly primitive implementation for dynamic dispatch, I use a cons list to store lists of patterns and bodies, sorted first by symbol and then by argument types.
Symbols are also interned into a cons list, later I will have to find a way to include them directly in compiled code.
Loops are expanded into State’s tagbody forms.
The parser is implemented in my Common Lisp version of OMeta, which I plan to port to Church later.
My future work is focussed on writing the Church and State compilers in Church itself, thus bootstrapping the language.