10

I've read JRM's Syntax-rules Primer for the Merely Eccentric and it has helped me understand syntax-rules and how it's different from common-lisp's define-macro. syntax-rules is only one way of implementing a syntax transformer within define-syntax.

I'm looking for two things, the first is more examples and explanations of syntax-rules and the second is good sources for learning the other ways of using define-syntax. What resources do you recommend?

3
  • I have a similar question today: more examples and explanations of syntax-rules and good sources for learning to use define-syntax but many ressources mentioned in the original responses to this answer no longer exist today or are not easily accessible. Any further update responses to this question? Commented Mar 22, 2023 at 16:15
  • Currently, 1. For the 2nd question, IMHO Guile syntax-case doc gnu.org/software/guile/manual/html_node/Syntax-Case.html is very readable for its format and elegant examples with related explanation. It also refers to one book by Kent Dybvig who is also said by Nathan Shively-Sanders. 2. For the 1st, IMHO "examples and explanations" from JRM's Syntax-rules Primer are enough. For "explanation", It is better to compare it with others like syntax-case. The Racket (i.e. PLT Scheme formerly) guide doc docs.racket-lang.org/guide/syntax-case.html say a bit about this. Commented Nov 21, 2024 at 9:03
  • Continued... The Racket reference doc shows more about API but also shows the relation implicitly docs.racket-lang.org/reference/…. This is also said in Guile syntax-case doc. Finally, IMHO Guile comparison between them are more readable gnu.org/software/guile/manual/html_node/…. Commented Nov 21, 2024 at 9:07

4 Answers 4

8

To answer your second question: syntax-case is the other form that goes inside define-syntax. Kent Dybvig is the primary proponent of syntax-case, and he has a tutorial on using it [PDF].

I also read the PLT Scheme documentation on syntax-case for a few more examples, and to learn about the variation in implementation.

Sign up to request clarification or add additional context in comments.

2 Comments

A recent syntax-case tutorial by Marc Nieper-Wißkirchen: Extending a Language — Writing Powerful Macros in Scheme
mnemenaut's link is so helpful, actually it is one macro tutorial including teaching syntax-case.
6

The JRM Syntax-rules primer is quite good, but Chapter 36 of Programming Languages: Application and Interpretation, by Shriram Krishnamurti http://www.cs.brown.edu/~sk/Publications/Books/ProgLangs/) also has good coverage of writing Scheme macros. That material has been used and improved over several short articles, tech reports, etc, over the past 10 years, so it's not a 'this was true about the X implementation of Scheme in 1983 that is no longer accessible' paper.

Comments

4

Fear of Macros is a practical guide for using macros in Racket. It shows many ways of using define-syntax. The material may not be completely applicable to Scheme, but you might find some of the examples useful for knowing what can be done.

Comments

4

The list of resources at The Scheme Cookbook is a great place to start. If you prefer papers, then don't hessitate to visit readscheme.org.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.