[racket] Newbie question: Teach Yourself Scheme in Fixnum Days - macros

From: Eli Barzilay (eli at barzilay.org)
Date: Mon Apr 4 19:25:49 EDT 2011

Four hours ago, Robby Findler wrote:
> 
> It looks like a great macro essay for a certain crowd (altho the
> essay seems to insult that selfsame crowd; perhaps you are assuming
> that that crowd is into S&M?).

Where's the insult?  (I didn't mean any insult -- the only thing I can
think of is the "nostalgia" reference, which is not an insult but the
often expressed sentiment for "a simple system, like `defmacro'".)


> Some comments:
> 
>  - I probably would have used #` in the second while macro. Yes, I
> see you mention it later, but doing it at that point seems to fit
> with what the reader's been given at that point

Well, that's one point where the purpose of the document is different
from a generic guide: my main goal was to write a quick intro to
people who are familiar with `defmacro' -- so I wanted to make it very
clear that it's the same kind of thing, only with wrapped sexprs
instead of raw ones.  In this case, I think that the long route is
better -- it shows that the extra tools (like #`) make things easier
only after you're aware of what goes on (and the fact that there's no
complicated magic involved, which is the frequent complain against
`syntax-case').


>  - it would be good if you did some kind of a computation at compile
> time, preferably to demonstrate an interesting computation one
> should want to do at compile time. Maybe a macro that embeds a
> formatted source location into its output?

Good idea, I'll add something.


>  - cpp macros are, I believe, based on lexemes, not strings (so you
> cannot have an unclosed string in a macro or something).

Yeah, I couldn't find a way to phrase it better than stick a random
"roughly" in.  Using "lexemes" is a good word to describe it, but it's
a little too opaque -- any ideas for something more light?


> At least nowadays they are.

Yes -- I definitely have used `#define's with a double-quote opener.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the users mailing list.