[plt-scheme] exception in local variable access from augmented method

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Dec 6 12:54:57 EST 2008

At Sat, 6 Dec 2008 12:42:10 -0500 (EST), Dimitris Vyzovitis wrote:
>    (define-syntax (~set! stx)
>      (syntax-case stx ()
>        ((_ tgt v)
>         (and (identifier? #'tgt)
>              (set!-transformer? (syntax-local-value #'tgt (lambda () #f))))
>         ((set!-transformer-procedure (syntax-local-value #'tgt)) stx))
>
> [...]
>
> 
> It seems the culprit here is the set! renaming breaking the transformer 
> syntax-id-rules (they match with free-identifier=?, don't they?)

Yes, that's right. The transformer procedure is expecting a syntax
object that matches

    (set! id ....) ; where `set!' is free-identifier=? to the usual one

but it's getting an object that matches

    (~set! id ....) ; where `~set!' is not free-identifier=? to `set!'

In other words, you're breaking a contract (that should be) on the
procedure of a `set!-transformer'.

For the particular transformer procedure inside the class system, since
the `set!' pattern doesn't match, the transformer assumes that it must
be getting a pattern of the form `(id ....)', and so it expands to a
procedure application.


Matthew



Posted on the users mailing list.