[plt-scheme] macro/hygiene, simple question
That's what I needed, thanks,
-- Éric
On Apr 9, 2010, at 5:37 PM, Chongkai Zhu wrote:
> Demand on what you want to achieve, this might be it:
>
> (define-syntax (curry-Z stx)
> (syntax-case stx ()
> ((curry-Z exp)
> #`(lambda (#,(datum->syntax #'curry-Z 'Z)) exp))))
>
> Chongkai
>
>
> Eric Tanter wrote:
>> Hi,
>>
>> I'm trying to define a simple macro that introduces a binder over any expression (thereby capturing what would otherwise a free var in the exp):
>>
>> example:
>> (curry-Z (lambda (x) (+ x Z)))
>> ==> (lambda (Z) (lambda (x) (+ x Z)))
>>
>> I define the curry-Z macro as follows:
>>
>> (define-syntax curry-Z
>> (syntax-rules ()
>> ((curry-Z exp)
>> (lambda (Z) exp))))
>>
>> However, I get a complaint that Z is undefined in the original program. This is not surprising because of hygiene. But I'd really much like to be able to force the capture to happen.
>> Is there a nice way to circumvent hygiene here and force capture?
>>
>> Thanks,
>>
>> -- Éric
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>