[r6rs-discuss] [Formal] Minor improvement to lisp-transformer

Abdulaziz Ghuloum aghuloum at cs.indiana.edu
Wed May 23 00:40:12 EDT 2007


---
This message is a formal comment which was submitted to formal-comment at r6rs.org, following the requirements described at: http://www.r6rs.org/process.html
---
submitter: Abdulaziz Ghuloum <aghuloum at cs.indiana.edu>
type: better example
priority: minor
component: syntax-case
version: 5.93-libs (page 54)
summary: The lisp-transformer macro can be improved slightly

The lisp-transformer example in page 54 does not yield true
lisp transformers (as its description says).

(define lisp-transformer
   (lambda (p)
     (lambda (x)
       (datum->syntax #'lisp-transformer
         (p (syntax->datum x))))))

Rewriting the example as:

(define lisp-transformer
   (lambda (p)
     (lambda (x)
       (syntax-case x ()
         [(id . rest) (identifier? #'id)
          (datum->syntax #'id
            (p (syntax->datum x)))]))))

will re-introduce the datum in the context where the actual
transformer was used instead of where the lisp-transformer
macro was defined.  defmacro is left as an exercise.

Aziz,,,




More information about the r6rs-discuss mailing list