[r6rs-discuss] [Formal] identifier-syntax is not a derived form

From: Andre van Tonder <andre>
Date: Tue Nov 14 12:55:38 2006

---
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
---
Name        : Andre van Tonder
Email       : andre at het.brown.edu
Type        : defect
Priority    : minor
Component   : libraries
Version     : 5.91
Pages       : 114
Dependencies: Libraries (phase semantics) and free-identifier=? (p. 112)
Summary:
--------
Identifier-syntax is not a derived form.
Discussion:
-----------
Identifier-syntax cannot currently be portably expressed as a derived form.
I know of two conforming implementations in which it can be so expressed only
with en extension to negative import levels.  A third implementation
can express identifier-syntax without negative import levels, but only
by violating the stated semantics of free-identifier=?.
Here is essentially how it must be espressed in two of these implementations:
(library (core identifier-syntax)
   (export identifier-syntax)
   (import (for (r6rs syntax-case base) run expand)
           (for (r6rs base) expand
                            run
                            (meta -1)))  ;; FOR LAST OCCURRENCE OF SET!
   (define-syntax identifier-syntax
     (lambda (x)
       (syntax-case x (set!)
         ((_ e)
          (syntax (lambda (x)
                    (syntax-case x ()
                      (id (identifier? (syntax id)) (syntax e))
                      ((_ x (... ...))              (syntax (e x (... ...))))))))
         ((_ (id exp1)
             ((set! var val) exp2))
          (and (identifier? (syntax id))
               (identifier? (syntax var)))
          (syntax
           (make-variable-transformer
            (lambda (x)
              (syntax-case x (set!)   ;; THIS IS THE PROBLEMATIC OCCURRENCE
                ((set! var val)               (syntax exp2))
                ((id x (... ...))             (syntax (exp1 x (... ...))))
                (id (identifier? (syntax id)) (syntax exp1))))))))))
   )
A third implementation does not require the "(meta -1)".  It does so by
modifying the semantics of free-identifier=?.  In this implementation, the
current definition
   "The free-identifier=? procedure returns #t if and only if the two identifiers
    would resolve to the same binding if both were to appear in the output of a
    transformer outside of any bindings inserted by the transformer."
no longer holds.
Suggestion:
-----------
Consider refining the semantics of phases, import levels and/or 
free-identifier=? to make identifier-syntax expressible as a derived form.
Alternatively, put free-identifier=? somewhere else than the "derived forms"
section.
Received on Tue Nov 14 2006 - 09:56:59 UTC

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