[racket] macro expansion function in Scheme

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Jul 12 10:17:30 EDT 2011


On Jul 12, 2011, at 10:16 AM, Eli Barzilay wrote:

> 8 minutes ago, Matthias Felleisen wrote:
>> 
>> The following experiment produces a bit more insight: 
>> 
>>> (((eval (expand '(m y))) #t) #f)
>> #t
>> 
>> The result of expand compiles to the correct closure. 
>> 
>> So the docs for syntax->datum are dead serious when they say that it
>> "returns a datum by stripping the lexical information, source
>> location information, properties, and tamper status from stx."
> 
> Try also the macro stepper.  From an upcoming package for the repl:
> 
>  -> (define-syntax m
>       (syntax-rules ()
>         ((_ x)
>          (lambda (x) (lambda (y) x)))))
>  -> ,stx (m y) *
>  syntax set
>  stepper:
>  Macro transformation
>  (m y)
>    ==>
>  (lambda:1 (y) (lambda:1 (y:1) y))
> 
> (But you'd usually want to use the gui version...)

Fire up drracket and run the stepper. 


Posted on the users mailing list.