greghendershott/fear-of-macros

Comments

jeapostrophe opened this issue · 10 comments

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

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:

  • first etc. would need a (require (for-syntax racket/list)) and I didn't want to get into that topic quite so early.
  • I don't mind if it looks somewhat confusing because it sets up pattern-matching as a better way to go about it. :)

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!

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!

@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.

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.

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

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:

  • in most cases where both pattern and template use body0 body1 ... it's probably sufficient to just use body ... (but you might have done that on purpose)
  • the silent introduction of quasisyntax and unsyntax-splicing was a bit of an ambush :)

@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.

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 :)

@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.

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