[racket] Struct & match magick

From: Roman Klochkov (kalimehtar at mail.ru)
Date: Tue Aug 19 08:32:33 EDT 2014

#lang racket
(require (for-syntax racket racket/struct-info))
(struct foo (a b))
(set! foo-a (let ([old foo-a])
                          (λ (x) (displayln x) (old x))))
(define t (foo 1 2))

(displayln "Before change")
(match t [(foo a b) a])

(let-syntax ([foo (extract-struct-info (syntax-local-value #'foo))])
   (displayln "After change")
   (match t [(foo a b) a]))

Gives:
Before change
1
After change
#<foo>
1

So, resetting foo to the same struct-info enable calling modified foo-a. But why?
Besides, if it is inevitable, how to redefine (like set!) the syntax?

-- 
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140819/b6998a9d/attachment.html>

Posted on the users mailing list.