Good afternoon! Macro newbie here,
I wanted to define a macro $: so that I could write this: (cond [$: p (Point x y) => (+ x y)]) and it would expand into this: (cond [(if (Point? p) p #f) => (match-lambda [(Point x y) (+ x y)])] [else #f]) I gave it a try: (define-syntax ($: stx) (syntax-case stx (=>) [(_ arg (struct-name field ...) => body) (with-syntax ([pred? (format-id stx "~a?" #'struct-name)]) #'[(if (pred? arg) arg #f) => (match-lambda ([(struct-name field ...) body]))])])) But this macro expands (or attempts to) after cond has expanded... which is not what I wanted. Is there a quick fix for this? Or can someone point me towards a particular spot in the documentation where I might educate myself? 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. Best, Andrew
____________________ Racket Users list: http://lists.racket-lang.org/users