I tend to use ,@ (splice) like this: `(p "foo" "bar" ,@(@when test-condition (do-something)))
where (define-syntax-rule (@when tst body) (if tst (list body) '())) On Jan 28, 2014, at 2:20 PM, Matthew Butterick <m...@mbtype.com> wrote: > I frequently write quasiquoted xexprs that contain this kind of pattern: > > `(p "foo" "bar" ,(when test-condition (do-something))) > > When test-condition is #f, I get: > > '(p "foo" "bar" #<void>) > > Which is wrong. What I wanted was: > > '(p "foo" "bar") > > I can fix it by doing this: > > (filter-not void? `(p "foo" "bar" ,(when test-condition (do-something)))) > > Is this the best way? Or is there a cleverer way to make the nested > expression completely disappear? > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users