The begin form can encapsulate multiple definitions like this: (require (for-syntax racket/sequence racket/syntax) syntax/parse/define)
(define-simple-macro (define-asserts predicate:id ...) #:with (assert-name ...) (for/list ([id (in-syntax #'(predicate ...))]) (format-id this-syntax "assert-~a" (syntax-e id))) (begin (define (assert-name response) (assert-lines response predicate)) ...)) Note that format-id needs to use this-syntax (from syntax parse, referring to the syntax object passed to the current syntax transformer) to obtain the right lexical context. On Tue, Nov 20, 2018 at 8:26 AM Brian Adkins <lojicdot...@gmail.com> wrote: > > I'm just beginning to dig in to Racket macros, so forgive the newbie question > :) Is it possible to create a macro that will result in multiple functions > being defined? > > I have a bunch of predicate functions, and I'm creating a parallel set of > assert functions that look like the following: > > (define (assert-at-home-page response) > (assert-lines response at-home-page?)) > > (define (assert-at-signon-page response) > (assert-lines response at-signon-page?)) > > ... > > It would be trivial to define a macro to create a single assert more nicely > than the above, but it would be nice to be able to use something like: > > (define-asserts at-home-page? at-inquiry-menu? at-signon-page? ... ) > > All of the macros I've experimented with thus far deal with a single form. > > Thanks, > Brian > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.