anophoric if example
sbloch opened this issue · 1 comments
Working my way through this tutorial; thanks!
Section 5 ends with "But we can still define it
as a normal variable" and an example of doing so. It doesn't mention that after one has defined it
as a normal variable, "aif" no longer works:
syntax-parameterize: not bound as a syntax parameter in: it
I tried to fix this by putting the define-syntax-parameter
in a local scope around the body of the macro definition:
(define-syntax aif
(local ((define-syntax-parameter it ; etc.))
(lambda (stx)
(syntax-case ; etc.))))
but apparently define-syntax-parameter
doesn't count as a "definition" for local
's purposes. And I suspect that if it
were defined only locally, it wouldn't serve the intended purpose anyway.
Thanks for catching this. What I should have written is that it
can still be defined locally. At the top level top level that you can't redefine it.
;; Although we can't redefine `it` at the top level -- that would conflict
;; with the syntax parameter -- we can still define `it` in a local context.
;; For example:
(let ([it "hi"])
it)
(define (foo)
(define it "hi")
it)
I'll update Scribble and push to the web site, when I have a bit more time, then mark this as closed. Thanks again!