[plt-scheme] define-syntax by itself

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Sep 9 17:55:52 EDT 2006

Jens Axel Søgaard skrev:
> Blake McBride skrev:

> A transformer must return a syntax-object as a result.
>> If I try:
>> (define-syntax foo
>>   (lambda (stx)
>>     (datum->syntax-object stx (car (syntax-object->datum stx)))))
>> (foo 6)
>> I get:  car: expects argument of type <pair>; given foo

Btw - Try this to see what syntax-object foo is called with.
Remember that you can "unfold" syntax-object in DrScheme
by clicking at the blue arrow.

(define-syntax foo
   (lambda (stx)
     (display stx) (newline)
     (datum->syntax-object stx
                           (car (syntax-object->datum stx)))))

(foo 6)

Also check out the macro debugger in the SVN version.

It shows that

  (foo 6) expands to foo

and that the expansion of


leads to the error you saw.

Jens Axel Søgaard

Posted on the users mailing list.