[plt-dev] syntax-local-value and identifier-mappings

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Mar 17 17:07:24 EDT 2009

At Mon, 9 Mar 2009 18:22:14 -0600, Matthew Flatt wrote:
> One last possibility, which I had not really considered until now, is
> to have the macro expander treat a transformer binding to a renamer by
> applying a syntax-object renaming immediately, instead of merely
> installing a transformer binding. That sounds promising to me, and I
> could give it a try next week or so.

This change is in SVN as v4.1.5.2.

When you bind an identifier as syntax to a rename transformer, the
parser installs a syntax-object equivalence to make the original and
new identifiers `free-identifier=?':

 > (define x 'whatever)
 > (define-syntax y (make-rename-transformer #'x))
 > (free-identifier=? #'x #'y)
 #t

This change should make things work better. For example,
`define-package' works more the way you'd expect with `syntax-rules'
literals:

  (define-package p (x y)
    (define-syntax x
      (syntax-rules (y)
        [(x y) 'y]
   	[(x z) 'other]))
    (define y 'placeholder))

  (let ()
    (open-package p)
    (x y)) ; => 'y, instead of 'other

Similarly, Typed Scheme's use of a `free-identifier=?' table to track
types should now cooperate automatically with forms like
`define-package' (or the `splicing-let' form that Ryan just posted to
plt-scheme).



Posted on the dev mailing list.