[plt-scheme] more macro

From: Ivanyi Peter (pivanyi at freemail.hu)
Date: Mon Aug 7 07:16:23 EDT 2006

Hi there,

I have noticed the following with macros. I could use macros
to remove the quote sign, for example:

(define-syntax m1
  (lambda (x)
    (syntax-case x ()
      ((_ 'f e1 e2 ...)
       (syntax (f e1 e2 ...))))))

(syntax-object->datum (expand-once #'(m1 't a b c d)))
(t a b c d)

I do not know whether it is a feature or a bug. However if I
use this
"feature", then I have a problem when I try to use the quote
inside the macro expansion, for example:

(define-syntax m2
  (lambda (x)
    (syntax-case x ()
      ((_ 'f e1 e2 ...)
         ((vars (map (lambda (x) (list x 'x)) 
                     (syntax-object->datum (syntax (e1 e2
           (((lvars ...) vars))
           (syntax (lvars ...))))))))

(syntax-object->datum (expand-once #'(m2 't a b c d)))
Expected result:
((a 'a) (b 'b) (c 'c) (d 'd))

On the other hand macro m2 would report an error saying:
quote: illegal use of syntax in: (quote x)

Is this a bug or a feature? I do not really understand what is 
happening with the quote sign inside these macros.


Another strange thing with macros, when I type this in DrScheme:

(syntax-object->datum (expand #'(require (lib "list.ss"))))

It expands to:

(require (lib "list.ss"))

Should not it expand to something with #%app and #%top and 
#%datum, to the most basic form? What is preventing it?

Thanks for your help.

Peter Ivanyi

FotoMarket - nyaralási képek akár ingyen! Minden digitális fényképezőgéphez 3.000,- Ft ajándék fotókidolgozás. http://ad.adverticum.net/b/cl,1,6022,99786,162268/click.prm

Posted on the users mailing list.