[racket] Expander vs Reader layer and general Macro advice
An hour ago, Jay McCarthy wrote:
> You can do this a complicated way and an easy way. The complicated
> way would have to deal with stuff like (f 1):5 and the easy way
> would just work on stuff like x:1. I see "string":e as being part of
> the complicated way. In my mind, the complicated way would have to
> be done with a reader that produced some syntax that the expander
> dealt with the rest of. The easy way would just be a #%top macro
> like you have.
There's a much easier way: use the built-in reader, then scan the
resulting syntax tree and tweak occurrences of `? : ?'. This of
course requires spaces around all `:'s -- but dealing with that should
be simple now: change the default reader table to make `:' a
terminating reader macro, and make it consume just the colon and
produce itself as an identifier for the previous hack to continue
working.
But the real problem with any of these is still the same: you need to
decide what to do with things like '(x:y) and a naive reader tweaker
would add confusions like (define (x : y) ...) (which quote etc
already are doing).
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!