Currying in apocrita

While apocrita is very limited language, it’s already complete enough that I can experiment with ideas and see how they work in practice (or in this case, how to implement an old and well known idea). And that old idea is currying (technically partial application, but close enough).

In partial application the language will detect if a function is being called without enough parameters. Instead of throwing an error, a new function is created and returned. This new function captures all the parameters that were supplied to the original function and can be called either normally or partially applied again (if there are more than one parameter left).

Continue reading

Metacircular evaluator

Every culture have their own rites of passage. Recently I passed one of those, as I wrote my own lisp interpreter. I chose to write on with Hy, as that is a language I currently enjoy most. I also found certain satisfaction in writing an interpreter with a language that closely resembles the language the interpreter is supposed to be working with. There are many lisps in the world and this one isn’t particularly special. But the goal wasn’t about creating something spectacular. The goal was to write a complete interpreter, learn while doing so and appreciate the elegance of the eval-apply – loop. I mostly following the excellent SICP lecture from 1986 by Gerald J. Sussman. There’s a little bit code here and there (most notably the reader part) that I crafted, instead of following what he was explaining.

Normally, people under 40 and who don’t have several children are advised to be careful. If they’re really worried, they should leave. Because there’s a certain amount of mysticism that will appear here which may be disturbing and cause trouble in your minds.

Continue reading