[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] R7RS final draft - bug report for section 7.3 Derived expression types



On Sun, Sep 8, 2013 at 11:20 PM, Joseph Wayne Norton <norton@x> wrote:

Hello.

For R7RS final draft, the syntax-rules for the case derived _expression_ appears to be incorrect.  The order of the 4th <syntax rule> is incorrect.

The 4th <syntax rule> should be moved after the 5th <syntax rule> .  If not, the result1 pattern variable of the 4th <syntax rule> will incorrectly match with an => in the input.

Thanks Joseph, you are correct.  We'll add this to the errata,
and I'll also add a case for this to the R7RS test suite, which
is currently only checking => for else clauses.
 

Best regards,

Joe N.


p.s. Here is a corrected version:

 (define-syntax case
   (syntax-rules (else =>)
     ((case (key ...)
        clauses ...)
      (let ((atom-key (key ...)))
        (case atom-key clauses ...)))
     ((case key
        (else => result))
      (result key))
     ((case key
        (else result1 result2 ...))
      (begin result1 result2 ...))
     ((case key
-       ((atoms ...) result1 result2 ...))
-     (if (memv key '(atoms ...))
-         (begin result1 result2 ...)))
-    ((case key
        ((atoms ...) => result))
      (if (memv key '(atoms ...))
          (result key)))
     ((case key
        ((atoms ...) => result)
        clause clauses ...)
      (if (memv key '(atoms ...))
          (result key)
          (case key clause clauses ...)))
     ((case key
+       ((atoms ...) result1 result2 ...))
+     (if (memv key '(atoms ...))
+         (begin result1 result2 ...)))
+    ((case key
        ((atoms ...) result1 result2 ...)
        clause clauses ...)
      (if (memv key '(atoms ...))
          (begin result1 result2 ...)
          (case key clause clauses ...)))))

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports


_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports