[plt-scheme] shouldn't this work?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Feb 20 10:14:03 EST 2007

The difference between the x and the y is that the x is introduced by
a macro and only variables introduced by the macro can be bound by
that x. Others x's will be different.

This is an important property for programming modularly with macros
(to avoid accidental name collisions). Its called "hygiene".

Robby

On 2/20/07, Derick Eddington <derick.eddington at gmail.com> wrote:
> This top-level begin form splicing does not seem to be working (with 360
> nor 369.8):
>
> Welcome to MzScheme version 360, Copyright (c) 2004-2006 PLT Scheme Inc.
> > (define-syntax hmm
>     (syntax-rules ()
>       [(_)
>        (begin
>          (define x 'lala)
>          (printf "can use x from here: ~s~n" x))]))
> > (hmm)
> can use x from here: lala
> > x  ;; shouldn't this binding exist?
> reference to undefined identifier: x
>
>  === context ===
> repl-loop
>
> > (begin  ;; just for comparison
>     (define y 'blah)
>     (printf "y = ~s~n" y))
> y = blah
> > y
> blah
>
> DrScheme's macro stepper shows (hmm) expanding to the expected begin
> form and the printf using x works, yet x is not bound at the top-level
> but y is.
>
> --
> : Derick
> ----------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.