Stylistically, one approach to mitigate this is to keep the name as close to the code that defines it as possible. Here's a macro version of for-each that allows you to place an anonymous transformer right near the list of expression arguments it will receive:
At least if you were doing a text search for the identifier name, it would show up immediately below the code that defines it.(define-syntax syntax-for-each
(syntax-rules ()
[(_ transformer (arg ...))
(begin
(define-syntax anonymous transformer)
(anonymous arg)
...)]))
(syntax-for-each (syntax-rules ()
[(_ name)
(begin
(define name #|whatever|#)
(provide name))]
(foo bar baz bat razzle frizzle fratz))
Incidentally, notice the use of the internal define-syntax. This is necessary, because if you use let-syntax, the code inside of it is no longer at the top level, so any definitions produced by the macro would be treated as internal defines. Yuck.
No comments:
Post a Comment