Syntactic Abstraction: The syntax-case Expander > Conclusion

25.4. Conclusion

The simplified expander described here illustrates the basic algorithm that underlies a complete implementation of syntax-case, without the complexities of the pattern-matching mechanism, handling of internal definitions, and additional core forms that are usually handled by an expander. The representation of environments is tailored to the single-binding lambda, let, and letrec-syntax forms implemented by the expander; a more efficient representation that handles groups of bindings would typically be used in practice. While these additional features are not trivial to add, they are conceptually independent of the expansion algorithm.

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.