[plt-scheme] shouldn't this work?

From: Richard Cleis (rcleis at mac.com)
Date: Tue Feb 20 10:11:47 EST 2007

The version is irrelevant.  This should work, and it is clear in the  
stepper:

(define-syntax hmm
   (syntax-rules ()
     ((_ from-top)
      (begin (define from-top 'lala)
             (printf "~s~n" from-top)))))

(hmm x)

x

12.3.3 explains that there is a difference between the top-level and  
the top-level-transformer environments.

rac



On Feb 20, 2007, at 6:37 AM, Derick Eddington 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.