Friday, March 27, 2009

Wise up. Flush Scheme.

I had a couple of conversations with Alan Bawden. I lobbied (unsuccessfully) to get a macro writing license from him. I didn't advance my case by mentioning that I had written a Scheme interpreter using syntax-rules. Alan is not a fan of syntax-rules.

I agree with Alan that implementing any sort of complex macro with syntax-rules is like forcing a program through a straw, but the alternatives are unpleasant, too. I like the fact that syntax-rules can be expanded without the need to invoke the interpreter, so phase mixing is impossible.

After Olin Shivers's talk about his loop macro, it occurred to me that Alan's observation about first-class macros having types (Clams got legs!) might be relevant. When a macro gets somewhat complex, it has to code walk its arguments. It needs to be able to distinguish between chunks of code and binding constructs. When a macro gets very complex (like Olin's loop macro), it becomes impossible to code walk. (Of course you can expand the inner macro away, but there are advantages to keeping it in its original form.) This makes it difficult to use moderately complex macros. I was thinking that Alan's ideas of marking the types of a macro could help during the code walking.