Macros

First, it was important to include macros in Better Scheme because of the great power they provide. Further, there would be no nice let etc.

Several possible forms of macros were considered during the course of designing Better Scheme. They were:

  1. Lazy Evaluation & Quoted Arguments - it was originally believed that lazy evaluation & quoted arguments would provide everything necessary for macros. Namely an argument's evaluation could be delayed as required for macros like if. In addition, the argument evaluation could be avoided as needed for macros involving variable names. However, a way to selectively evaluate subparts of unevaluated expressions was needed. The idea of allowing the decomposition of a lazy evaluated argument into lazy evaluated subparts was considered, as were many other possibilities but no satisfactory solution was found.
  2. Evaluation of Return - borrowing from Lisp the idea of allowing the return value to be evaluated in the calling environment was considered. Thus, a macro would simply construct an expression and return it. It would then be evaluated in the calling environment. This even seemed to parallel the concept of quoted arguments. Yet, there were subtle problems.
  3. Hygienic Macros - Scheme's answer to the subtle problems of Lisp style macros was hygienic macros and they are very cool indeed. Yet, in Scheme macros aren't first class values.

Resolution

Hygienic macros were adopted. However, they are changed from Scheme to make them first class values and their syntax is more symmetric with functions. There is no good reason Scheme's macros aren't first class except that it would be hard to compile. Better Scheme is meant to be interpreted and so isn't as concerned with that. Hope is still held out that some sort of flow analysis will allow Better Scheme to be compiled even in the face of first class hygienic macros.



jwalker@cs.oberlin.edu