[plt-scheme] Macro changing behaviour

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Apr 21 18:37:30 EDT 2009

This will work:

#lang scheme

(define-syntax-rule (test proc . args)
   (apply proc 'args))

(test (lambda () (+ 1 1)))

So does this:

(define-syntax-rule (test proc args ...)
   (apply proc (list args ...)))

(test (lambda () (+ 1 1)))

which I consider a bit more elegant. -- Matthias

P.S. Oh and do use the macro stepper. It works.



On Apr 21, 2009, at 6:30 PM, Paulo J. Matos 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?
>
> Cheers,
> -- 
> Paulo Jorge Matos - pocmatos at gmail.com
> Webpage: http://www.personal.soton.ac.uk/pocm
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.