<div>Good afternoon!</div><div><br></div><div>Macro newbie here,<br></div><div><br></div>I wanted to define a macro $: so that I could write this:<div><br></div><div><div>(cond</div><div>  [$: p (Point x y) => (+ x y)])</div></div><div><br></div><div>and it would expand into this:</div><div><br></div><div><div>(cond</div><div>    [(if (Point? p) p #f) </div><div>     => (match-lambda [(Point x y) (+ x y)])]</div><div>    [else #f])</div></div><div><br></div><div>I gave it a try:</div><div><br></div><div><div>(define-syntax ($: stx) </div><div>  (syntax-case stx (=>)</div><div>    [(_ arg (struct-name field ...) => body)</div><div>     (with-syntax ([pred? (format-id stx "~a?" #'struct-name)])</div><div>       #'[(if (pred? arg)</div><div>              arg</div><div>              #f)</div><div>          =></div><div>          (match-lambda ([(struct-name field ...) body]))])]))</div></div><div><br></div><div><br></div><div>But this macro expands (or attempts to) after cond has expanded... which is not what I wanted.</div><div><br></div><div>Is there a quick fix for this? Or can someone point me towards a particular spot in the documentation where I might educate myself?</div><div><br></div><div>I know about match (we're great friends)---I was just toying around with this to see if I could get cond to look pretty w/ structs as well.</div><div><br></div><div>Best,</div><div>Andrew</div>