Unlambda to D Compiler

David Madore wrote, on his Unlambda page, a discussion of the question of whether Unlambda can be compiled.  His answer was to the effect that there are potential difficulties, but he wasn't sure if they can be overcome.

In particular, the difficulties mentioned are the c and d builtins.  Apparently c should be doable if the language has first-class continuations, or otherwise by using continuation-passing style.  And d is somewhat harder to deal with.

It turns out that I had little difficulty in dealing with d, thanks to D's lazy function parameters, which are akin to Unlambda's 'promises' (a bit of a misnomer actually).  On the other hand, I wasn't sure how to get CPS to work, and so c doesn't work properly.  Meanwhile, I've got it implemented using an exception, which works as long as it doesn't escape from the c call.

Download