I am confused by the documentation about the usage syntax-case, but what can f possibly mean?
(define-syntax (check stx)
(syntax-case stx ()
[(f (x y))
#'(list 'second: f x y)]))
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This code is broken in a fairly subtle way.
To begin with,
Yields an error: check: bad syntax in: check
The problem, though, is the use of ‘f’ that appears in the expansion. To see this, try taking it out:
This evaluates fine, producing ‘(second: 1234 3 4)
So, why does the first one fail? The problem is that in your first example,
expands into
The problem with this, though, is that the ‘check’ in the expansion is another use of the ‘check’ macro, and must therefore be further expanded, and this second expansion does not have the right shape.
To see this, you can try expanding your program using the macro stepper. Run the macro stepper, use the pull-down menu to select “Standard” macro hiding, click on the “End–>” button, and then go back one step.
The normal convention is to use the underscore “_” as a “don’t care” symbol to match against the name of the macro in the pattern, like this:
Out of curiosity: where does this code come from?