on psyntax
For the last few months I've been on a Dybvig kick. He writes clearly, and his papers make sense.
In the last week or two I've been poking at integrating psyntax closer to the heart of Guile, and in doing so have grown familiar with the syntax-case algorithms.
The algorithms themselves are described as lucidly as they can be in a chapter of Beautiful Code.
On the one hand, psyntax is beautiful. It is written in Scheme + syntax-case, yet it transforms code from Scheme + syntax-case to primitive Scheme. It's a compiler, like ones written in Scheme that compile Scheme to native code. You have to bootstrap it with a precompiled version of itself.
On the other hand, Dybvig himself damns it with faint praise, comparing it to an earlier algorithm, KFFD:
The syntax-case expander extends the KFFD hygienic macro-expansion algorithm with support for local syntax bindings and controlled capture, among other things, and also eliminates the quadratic expansion overhead of the KFFD algorithm. The KFFD algorithm is simple and elegant, and an expander based on it could certainly be a beautiful piece of code. The syntax-case expander, on the other hand, is of necessity considerably more complex. It is not, however, any less beautiful, for there can still be beauty in complex software as long as it is well structured and does what it is designed to do.
In other words: it works, dammit, shut up and eat your porridge!
One response
Comments are closed.
> In the last week or two I've been poking at integrating
> psyntax closer to the heart of Guile
How so?