[plt-scheme] Macro changing behaviour
On Tue, Apr 21, 2009 at 6:30 PM, Paulo J. Matos <pocmatos at gmail.com> wrote:
> Hi all,
>
> I have a simple issue:
> (define-syntax-rule (test proc . args)
> (apply proc args))
> (test (lambda () (+ 1 1)))
>
> doesn't work. Generates:
> #%app: missing procedure expression; probably originally (), which is
> an illegal empty application in: (#%app)
>
> But this works:
> (apply (lambda () (+ 1 1)) '())
>
> So, somewhere this goes wrong. Can someone explain me what's the issue?
Where did the apostrophe come from? You added a quote around the ()
in your apply expression that isn't present in your macro. That's why
they get different results. I suggest you replace (apply proc args)
with (apply proc (list . args)) in your macro and replace '() with
(list) in your comparison expression; then they should reflect the
same thing.
--
Carl Eastlund