[racket] question about macro failing due to hygiene(?)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Why doesn't this work (expand: unbound identifier in module in: a):
#lang racket
(struct variable ((value #:mutable) rule))
(define-syntax make-store
(syntax-rules ()
((_ ((_id_ _rule_) ...))
(letrec-syntaxes+values
(((make-variable)
(syntax-rules ()
((_ #f) (variable #f #f))
((_ __rule__)
(variable
#f
(lambda ()
(let-syntax
((_id_
(syntax-id-rules ()
(_ (hash-ref store '_id_))))
...)
__rule__)))))))
(((store)
(make-hash
`((_id_ . ,(make-variable _rule_)) ...))))
store))))
(define simple-arith
(make-store
((a #f)
(b (* 3 a))
(c (+ 5 a b))
(d (let ((a 9)) (- c a))) )))
while this does work (but doesn't do what I want):
#lang racket
(struct variable ((value #:mutable) rule))
(define-syntax make-store
(syntax-rules ()
((_ ((_id_ _rule_) ...))
(letrec
((store
(make-hash
`((_id_
.
,(variable
#f
(lambda ()
(let-syntax
((_id_
(syntax-id-rules ()
(_ (hash-ref store '_id_))))
...)
_rule_)))) ...))))
store)) ))
(define simple-arith
(make-store
((a #f)
(b (* 3 a))
(c (+ 5 a b))
(d (let ((a 9)) (- c a))) )))
(variable-rule (hash-ref simple-arith 'a)) ; I want this to be #f
Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk8QY4MACgkQp/VmCx0OL2z4qQCgtHc9obw2H+FYN4GYukxLw59x
PLcAoKEM0ahoRdiacKCZjSCa36lLwedJ
=fitT
-----END PGP SIGNATURE-----