[plt-scheme] macro/hygiene, simple question

From: Eric Tanter (etanter at dcc.uchile.cl)
Date: Fri Apr 9 17:24:58 EDT 2010

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


Posted on the users mailing list.