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

From: Abdulaziz Ghuloum <aghuloum>
Date: Wed, 23 May 2007 00:40:12 -0400

---
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,,,
Received on Wed May 23 2007 - 00:40:12 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC