[racket-dev] struct + match not interacting via a macro
What exactly does the struct form of match (in the ASL language) use
to identify the structure? The following works fine:
(define-struct foo (a b))
(match (make-foo 1 2)
[(struct foo (x y))
(+ x y)])
But I have a macro over define-struct for which I get the error
match: foo does not refer to a structure definition in: foo
(pointing at the "foo" in "struct foo (x y)").
My macro uses build-struct-names to synthesize the names of the
constructor, selectors, etc. It binds all these names (including the
"struct:foo" name); for good measure I'm also binding "foo". The
coloring in the Macro Stepper isn't instructive (to me, anyway --
there is only one step of reduction before the error).
Here is the sample output (... elides irrelevant detail):
(define-struct: foo ([a : Number$] [b : Number$]))
-->
(begin
(define-values (foo struct:foo make-foo foo? foo-a set-foo-a!
foo-b set-foo-b!)
(let ()
(begin
(define-struct foo (a b) #:transparent #:mutable)
(let ([make-foo
(lambda (a b) ...)]
[set-foo-a! (lambda (struct-inst new-val) ...)]
[set-foo-b! (lambda (struct-inst new-val) ...)])
(values foo struct:foo make-foo foo? foo-a set-foo-a!
foo-b set-foo-b!))))))
Any ideas?
Shriram