[racket] tutorial: exploring the boundaries of outer space

From: Brian Mastenbrook (brian at mastenbrook.net)
Date: Wed Apr 11 10:28:17 EDT 2012

On Apr 11, 2012, at 7:45 AM, Danny Yoo wrote:

> Yikes.  Yes, that's unexpected.  Nice catch!

Hi Danny,

I confess that I had hidden motives in raising this scenario. What happened in this case is most definitely intended behavior for syntax parameters. This particular kind of weirdness is exactly the kind of brokenness you get from unhygienic insertion in Common Lisp, which is why I don't like syntax parameters very much. They don't compose very well, since as a macro author I can't use a macro which uses syntax parameters without those parameters becoming part of the interface of my own macro. This problem still remains in your newest version of `def', since as a user of `m' I still need to know that it uses `def' internally. The only way that I can see to avoid exposing this is to have `m' carefully capture and restore the values of any parameters used by `def', which is an extremely fragile solution. If syntax parameters become more common in Racket, I fear that macro writing will start to feel like tiptoeing through a minefield.

In this particular case, I think the "ordinary" datum->syntax insertion version of `def' behaves much more intuitively than the syntax-parameterized version, but it has problems with things like (let ((outer 1)) (def (f) outer) (f)). I believe it should be possible to solve that problem generally without the weirdness of syntax parameters, but I haven't had the time to devote to finding that solution.

It would be interesting to have Eli weigh in on this thread, since I know he disagrees with my views on this particular issue. :-)

Brian

--
Brian Mastenbrook
brian at mastenbrook.net
http://brian.mastenbrook.net/

Posted on the users mailing list.