greghendershott / fear-of-macros

A practical guide to Racket macros
250 stars 27 forks source link

Comments #1

Open jeapostrophe opened 11 years ago

jeapostrophe commented 11 years ago

our-if-v2 should use first, second, third, etc because the c(a|d)*rs are confusing

3.5 - define-syntax inside of begin-for-syntax doesn't mean what you think it means. That defines a macro for the syntax-phase (the syntax-syntax-phase) not a macro for the runtime-phase. The macro wouldn't be able to refer to the helper.

4 - syntax-parse came after match (but syntax-case came before)

4 - the switch from match to syntax-case also starts using #' rather than datum->syntax which is another big change (re hygiene)

5 - I think the use of make-rename-transformer needs explanation

greghendershott commented 11 years ago

Thank you so much for the feedback!

our-if-v2 should use first, second, third, etc because the c(a|d)*rs are confusing

That was deliberate:

3.5 - define-syntax inside of begin-for-syntax doesn't mean what you think it means. That defines a macro for the syntax-phase (the syntax-syntax-phase) not a macro for the runtime-phase. The macro wouldn't be able to refer to the helper.

Oops; I hadn't meant to nest it. Will fix.

4 - syntax-parse came after match (but syntax-case came before)

Good catch. I meant to write syntax-rules there.

4 - the switch from match to syntax-case also starts using #' rather than datum->syntax which is another big change (re hygiene)

OK, I'll work on that.

5 - I think the use of make-rename-transformer needs explanation

I'll work on that.

Thanks again!

tim-brown commented 11 years ago

Excellent article, thanks (it's only a slight over-egging to call it "life-changing")!

I wonder how large the demographic you describe in the preface is. It contains at least you and me!

greghendershott commented 11 years ago

@tim-brown Thank you.

wonder how large the demographic you describe in the preface is.

Yeah, "25 years of C/C++" -> Racket is probably not so common. :)

Perhaps it could also be helpful to people learning Racket after (say) five years of Python, Java, or another Not-Lisp.

skbach commented 11 years ago

Really helpful. This was exactly the bridge I needed to start understanding the Racket Guide / Manual on macros which was a bit over my head.

greghendershott commented 11 years ago

@skbach Thank you for letting me know, I'm glad it was helpful.

pdikmann commented 11 years ago

Awesome. Thank you for explaining macros from the business end (using syntax-case) and showing how define-syntax-rule is actually a sugared shortcut. For me, at least, that turned out to be pivotal in understanding macros (and the otherwise spotless Racket Guide about them) at all!

2 things:

greghendershott commented 11 years ago

@dikidoom Thank you for the feedback. I'm glad you liked it.

  1. ... means "zero or more". body0 body1 ... idiom is a way to to say "one or more", which is usually what you want. However I should explain that. And I could also mention that syntax-parse adds a ...+ meaning one-or-more.
  2. I should probably explain quaisyntax more. If I over-explain things then it can become a distraction, but if it's an ambush then it's worth the detour to introduce it.

Thanks again.

stchang commented 11 years ago

Hi Greg,

Thanks for the great article. Finally got around to checking it out. Sounds like I went through a similar learning process, but I don't think I would have been able to explain things as elegantly.

\ One comment: In the syntax parameters section, perhaps some motivation would improve the transition from the previous section? Specifically, maybe show why the previously introduced datum->syntax technique doesn't quite work? As currently presented, it reads a little like there are two solutions to the same problem but no explanation of which one to use. You don't have to go into as much detail as the Keeping It Clean paper, but even just alluding that the naive solution (ie, datum->syntax) has some problems would help I think.

\ Some random typos: ) 2 typos, section 3.2, 2nd sentence:

But typically we will want to transform in the input syntax into somehing else. => But typically we will want to transform the input syntax into something else.

) section 7.3, "Kenau" is misspelled :)

greghendershott commented 11 years ago

@stchang Thank you for the feedback!

I need to find time soon to make an editing pass to incorporate your suggestions as well as some of the others in this thread.

dgoffredo commented 6 years ago

This is the explanation of macros that I've been looking for. Thanks for writing this.