On Sep 14, 4:38 am, Abdulaziz Ghuloum <[email protected]> wrote:
> On Sep 14, 2009, at 5:21 AM, Eduardo Cavazos wrote:
>
> > But, I'm wondering, why doesn't this work:
>
> > (define-syntax import-procedure
> > (syntax-rules ()
> > ((import-procedure library name)
> > (let ()
> > (import library)
> > name))))
>
> For the same reason why
>
> (define-syntax get-something
> (syntax-rules ()
> ((_ name)
> (let ()
> (define something 'something)
> name))))
>
> (get-something something)
>
> doesn't work. That's hygiene.
>
> Aziz,,,
Hmm, interestingly the first one "works" in Petite Chez:
juer...@nix:~$ petite
Petite Chez Scheme Version 7.9.3
Copyright (c) 1985-2009 Cadence Research Systems
> (library (foo)
(export bar)
(import (rnrs))
(define bar 'bar))
> (define-syntax import-procedure
(syntax-rules ()
((_ library name)
(let ()
(import library)
name))))
> (define b (import-procedure (foo) bar))
> b
bar
>
while the second one doesn't.
And here is one that works for Ikarus:
(define-syntax import-procedure
(lambda (stx)
(syntax-case stx ()
((_ library name)
(with-syntax ((name (datum->syntax #'whatever (syntax->datum
#'name))))
#`(let ()
(import (only library name))
name))))))