On Feb 15, 2014, at 8:05 PM, Matthew Butterick wrote: > The macro noob (me) is experimenting with a macro that operates on define. I > understand how to match the three common forms of define: > > (define-syntax (define/foo stx) > (syntax-case stx () > [(_ (name arg ... . rest-arg) body ...) > #'(omitted)] > [(_ (name arg ...) body ...) > #'(omitted)] > [(_ name body ...) > #'(omitted)])) > > But how do I handle curried function definitions? Since they can be nested to > arbitrary depth, I'm puzzled. Is there a way to match them directly in > syntax-case? Or do I need a preliminary step of converting them into the > basic define form, like so: > > (define/foo (((bar a) b) c) > (+ a b c)) > > (define/foo bar > (λ(a) (λ(b) (λ(c) (+ a b c))))) > > ... and then send them through the syntax-case I've already got.
I would definitely go the second route. It's an obvious match and remains readable for the maintainer. ____________________ Racket Users list: http://lists.racket-lang.org/users