[plt-dev] Symptom of REPL's hopelessness?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Oct 1 17:58:03 EDT 2009

Oh man. That's subtle. Thanks.

On Oct 1, 2009, at 3:30 PM, Ryan Culpepper <ryanc at ccs.neu.edu> wrote:

> On Oct 1, 2009, at 4:19 PM, Robby Findler wrote:
>
>> What is the difference between generate-temporaries and gensym?
>
> 'generate-temporaries' returns identifiers that don't have an  
> associated '#%top' binding, but 'gensym' returns a symbol, which  
> gets coerced into an identifier using the lexical context of the  
> 'with-syntax' form, which does have a binding of '#%top' in scope.
>
> Ryan
>
>
>> On Thu, Oct 1, 2009 at 3:11 PM, Sam TH <samth at ccs.neu.edu> wrote:
>>> On Thu, Oct 1, 2009 at 4:01 PM, Casey Klein
>>> <clklein at eecs.northwestern.edu> wrote:
>>>> Can someone explain why this macro expands without error in a  
>>>> module
>>>> but not in the REPL?
>>>>
>>>> (define-syntax (m stx)
>>>> (syntax-case stx ()
>>>>  [(_ x)
>>>>   (with-syntax ([(y) (generate-temporaries (syntax (x)))])
>>>>     (syntax (define (y) y)))]))
>>>>
>>>>> (m q)
>>>> compile: unbound identifier (and no #%top syntax transformer is  
>>>> bound) in: q1
>>>
>>> This version of the macro works:
>>>
>>> (define-syntax (m stx)
>>> (syntax-case stx ()
>>> [(_ x)
>>>  (with-syntax ([(y) (list (gensym (syntax-e #'x)))])
>>>    (syntax (define (y) y)))]))
>>>
>>> --
>>> sam th
>>> samth at ccs.neu.edu
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://list.cs.brown.edu/mailman/listinfo/plt-dev
>>>
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-dev
>


Posted on the dev mailing list.