[plt-scheme] Re: define-syntax help
At Sat, 24 Mar 2007 13:48:10 -0500, "Jacob Matthews" wrote:
> but fortunately there's an
> easy fix. Replace the definition of register with this: [...]
>
> (let ([ht *field-hash*])
> (syntax-parameterize ((lookup-context #'obj))
> (hash-table-put! ht 'object-symbol expr)))))]))
or
(let ()
(syntax-parameterize ((lookup-context #'obj))
(hash-table-put! *field-hash* 'object-symbol expr)))
The problem was a bug in MzScheme, now fixed in SVN.
Specifically, the expansion of the macro result causes a
`letrec-syntaxes' (from `syntax-parameterize') to be replaced by a
`begin'. But the certificates on the `letrec-syntaxes' form were not
properly transferred to the `begin', and they got lost. The repaired
MzScheme expands away `letrec-syntaxes' to `let-values', instead, which
avoids a couple of potential problems, including lost certificates.
Wrapping the `syntax-parameterize' with a `let' anchored the relevant
certificate to a form that survives expansion, so that's why it worked
around the bug.
Matthew