allow definitions in with-syntax body
authorAndy Wingo <wingo@pobox.com>
Thu, 31 Mar 2011 11:23:27 +0000 (13:23 +0200)
committerAndy Wingo <wingo@pobox.com>
Thu, 31 Mar 2011 11:23:27 +0000 (13:23 +0200)
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
  as seems to be suggested by the R6RS.

* test-suite/tests/syncase.test ("with-syntax"): Add test.

* module/ice-9/psyntax-pp.scm: Regenerate.

module/ice-9/psyntax-pp.scm
module/ice-9/psyntax.scm
test-suite/tests/syncase.test

index fb862d0193b61e05f7add44326c9cb253954f84b..5c26e96c376078ccd327360ec8849861d97f475c 100644 (file)
                  (begin
                    (#{andmap\ 225}# #{first\ 203}# #{rest\ 204}#))))))))))
   (begin
-    (let ((#{make-primitive-ref\ 244}# (if #f #f))
-          (#{fx+\ 283}# (if #f #f))
+    (let ((#{fx+\ 283}# (if #f #f))
           (#{fx-\ 285}# (if #f #f))
           (#{fx=\ 287}# (if #f #f))
-          (#{fx<\ 289}# (if #f #f))
-          (#{set-syntax-object-expression!\ 354}#
-            (if #f #f))
-          (#{set-syntax-object-wrap!\ 356}# (if #f #f))
-          (#{set-syntax-object-module!\ 358}# (if #f #f))
-          (#{ribcage?\ 400}# (if #f #f)))
+          (#{fx<\ 289}# (if #f #f)))
       (letrec*
         ((#{make-void\ 240}#
            (lambda (#{src\ 750}#)
                                                           '(#(syntax-object
                                                               #f
                                                               ((top)
+                                                               #(ribcage
+                                                                 ()
+                                                                 ()
+                                                                 ())
                                                                #(ribcage
                                                                  #(k)
                                                                  #((top))
                             (cons #{vars\ 2791}# #{ls\ 2792}#))))))))
                (begin (#{lvl\ 2790}# #{vars\ 2784}# '() '(())))))))
         (begin
-          (set! #{make-primitive-ref\ 244}#
-            (lambda (#{src\ 756}# #{name\ 757}#)
-              (make-struct/no-tail
-                (vector-ref %expanded-vtables 2)
-                #{src\ 756}#
-                #{name\ 757}#)))
+          (lambda (#{src\ 756}# #{name\ 757}#)
+            (make-struct/no-tail
+              (vector-ref %expanded-vtables 2)
+              #{src\ 756}#
+              #{name\ 757}#))
+          (lambda (#{x\ 1134}# #{update\ 1135}#)
+            (vector-set! #{x\ 1134}# 1 #{update\ 1135}#))
+          (lambda (#{x\ 1138}# #{update\ 1139}#)
+            (vector-set! #{x\ 1138}# 2 #{update\ 1139}#))
+          (lambda (#{x\ 1142}# #{update\ 1143}#)
+            (vector-set! #{x\ 1142}# 3 #{update\ 1143}#))
+          (lambda (#{x\ 1223}#)
+            (if (vector? #{x\ 1223}#)
+              (if (= (vector-length #{x\ 1223}#) 4)
+                (eq? (vector-ref #{x\ 1223}# 0) 'ribcage)
+                #f)
+              #f))
           (set! #{fx+\ 283}# +)
           (set! #{fx-\ 285}# -)
           (set! #{fx=\ 287}# =)
           (set! #{fx<\ 289}# <)
-          (set! #{set-syntax-object-expression!\ 354}#
-            (lambda (#{x\ 1134}# #{update\ 1135}#)
-              (vector-set! #{x\ 1134}# 1 #{update\ 1135}#)))
-          (set! #{set-syntax-object-wrap!\ 356}#
-            (lambda (#{x\ 1138}# #{update\ 1139}#)
-              (vector-set! #{x\ 1138}# 2 #{update\ 1139}#)))
-          (set! #{set-syntax-object-module!\ 358}#
-            (lambda (#{x\ 1142}# #{update\ 1143}#)
-              (vector-set! #{x\ 1142}# 3 #{update\ 1143}#)))
-          (set! #{ribcage?\ 400}#
-            (lambda (#{x\ 1223}#)
-              (if (vector? #{x\ 1223}#)
-                (if (= (vector-length #{x\ 1223}#) 4)
-                  (eq? (vector-ref #{x\ 1223}# 0) 'ribcage)
-                  #f)
-                #f)))
           (begin
             (#{global-extend\ 376}#
               'local-syntax
             (@apply
               (lambda (#{e1\ 4203}# #{e2\ 4204}#)
                 (cons '#(syntax-object
-                         begin
+                         let
                          ((top)
                           #(ribcage
                             #(e1 e2)
                           #(ribcage () () ())
                           #(ribcage #(x) #((top)) #("i4198")))
                          (hygiene guile))
-                      (cons #{e1\ 4203}# #{e2\ 4204}#)))
+                      (cons '() (cons #{e1\ 4203}# #{e2\ 4204}#))))
               #{tmp\ 4200}#)
             (let ((#{tmp\ 4206}#
                     ($sc-dispatch
                           '()
                           (list #{out\ 4211}#
                                 (cons '#(syntax-object
-                                         begin
+                                         let
                                          ((top)
                                           #(ribcage
                                             #(out in e1 e2)
                                           #(ribcage () () ())
                                           #(ribcage #(x) #((top)) #("i4198")))
                                          (hygiene guile))
-                                      (cons #{e1\ 4213}# #{e2\ 4214}#)))))
+                                      (cons '()
+                                            (cons #{e1\ 4213}#
+                                                  #{e2\ 4214}#))))))
                   #{tmp\ 4206}#)
                 (let ((#{tmp\ 4216}#
                         ($sc-dispatch
                               '()
                               (list #{out\ 4221}#
                                     (cons '#(syntax-object
-                                             begin
+                                             let
                                              ((top)
                                               #(ribcage
                                                 #(out in e1 e2)
                                                 #((top))
                                                 #("i4198")))
                                              (hygiene guile))
-                                          (cons #{e1\ 4223}# #{e2\ 4224}#)))))
+                                          (cons '()
+                                                (cons #{e1\ 4223}#
+                                                      #{e2\ 4224}#))))))
                       #{tmp\ 4216}#)
                     (syntax-violation
                       #f
                                    (list '#(syntax-object
                                             let
                                             ((top)
+                                             #(ribcage () () ())
                                              #(ribcage
                                                #(body binding)
                                                #((top) (top))
                                     (list '#(syntax-object
                                              let
                                              ((top)
+                                              #(ribcage () () ())
                                               #(ribcage
                                                 #(step)
                                                 #((top))
                                           '#(syntax-object
                                              doloop
                                              ((top)
+                                              #(ribcage () () ())
                                               #(ribcage
                                                 #(step)
                                                 #((top))
                                           (list '#(syntax-object
                                                    if
                                                    ((top)
+                                                    #(ribcage () () ())
                                                     #(ribcage
                                                       #(step)
                                                       #((top))
                                                 (list '#(syntax-object
                                                          not
                                                          ((top)
+                                                          #(ribcage () () ())
                                                           #(ribcage
                                                             #(step)
                                                             #((top))
                                                 (cons '#(syntax-object
                                                          begin
                                                          ((top)
+                                                          #(ribcage () () ())
                                                           #(ribcage
                                                             #(step)
                                                             #((top))
                                                         (list (cons '#(syntax-object
                                                                        doloop
                                                                        ((top)
+                                                                        #(ribcage
+                                                                          ()
+                                                                          ()
+                                                                          ())
                                                                         #(ribcage
                                                                           #(step)
                                                                           #((top))
                                                     #(e1 e2)
                                                     #((top) (top))
                                                     #("i4336" "i4337"))
+                                                  #(ribcage () () ())
                                                   #(ribcage
                                                     #(step)
                                                     #((top))
                                                     #(e1 e2)
                                                     #((top) (top))
                                                     #("i4336" "i4337"))
+                                                  #(ribcage () () ())
                                                   #(ribcage
                                                     #(step)
                                                     #((top))
                                                           #(e1 e2)
                                                           #((top) (top))
                                                           #("i4336" "i4337"))
+                                                        #(ribcage () () ())
                                                         #(ribcage
                                                           #(step)
                                                           #((top))
                                                                 #((top) (top))
                                                                 #("i4336"
                                                                   "i4337"))
+                                                              #(ribcage
+                                                                ()
+                                                                ()
+                                                                ())
                                                               #(ribcage
                                                                 #(step)
                                                                 #((top))
                                                                 #((top) (top))
                                                                 #("i4336"
                                                                   "i4337"))
+                                                              #(ribcage
+                                                                ()
+                                                                ()
+                                                                ())
                                                               #(ribcage
                                                                 #(step)
                                                                 #((top))
                                                                                 (top))
                                                                               #("i4336"
                                                                                 "i4337"))
+                                                                            #(ribcage
+                                                                              ()
+                                                                              ()
+                                                                              ())
                                                                             #(ribcage
                                                                               #(step)
                                                                               #((top))
                                                      #(dy)
                                                      #((top))
                                                      #("i4445"))
+                                                   #(ribcage () () ())
                                                    #(ribcage
                                                      #(x y)
                                                      #((top) (top))
                                                      #(dy)
                                                      #((top))
                                                      #("i4445"))
+                                                   #(ribcage () () ())
                                                    #(ribcage
                                                      #(x y)
                                                      #((top) (top))
                                                      #(dy)
                                                      #((top))
                                                      #("i4445"))
+                                                   #(ribcage () () ())
                                                    #(ribcage
                                                      #(x y)
                                                      #((top) (top))
                                                #(stuff)
                                                #((top))
                                                #("i4454"))
+                                             #(ribcage () () ())
                                              #(ribcage
                                                #(x y)
                                                #((top) (top))
                                                    #(stuff)
                                                    #((top))
                                                    #("i4457"))
+                                                 #(ribcage () () ())
                                                  #(ribcage
                                                    #(x y)
                                                    #((top) (top))
                                                  #(_)
                                                  #((top))
                                                  #("i4459"))
+                                               #(ribcage () () ())
                                                #(ribcage
                                                  #(x y)
                                                  #((top) (top))
                                    (cons '#(syntax-object
                                             "append"
                                             ((top)
+                                             #(ribcage () () ())
                                              #(ribcage
                                                #(p)
                                                #((top))
                                (cons '#(syntax-object
                                         "append"
                                         ((top)
+                                         #(ribcage () () ())
                                          #(ribcage
                                            #(p y)
                                            #((top) (top))
                                               (list '#(syntax-object
                                                        "list->vector"
                                                        ((top)
+                                                        #(ribcage () () ())
                                                         #(ribcage
                                                           #(#{\ g4543}#)
                                                           #((m4544 top))
                                      (cons '#(syntax-object
                                               "vector"
                                               ((top)
+                                               #(ribcage () () ())
                                                #(ribcage
                                                  #(#{\ g4516}#)
                                                  #((m4517 top))
                                    (cons '#(syntax-object
                                             list
                                             ((top)
+                                             #(ribcage () () ())
                                              #(ribcage
                                                #(#{\ g4558}#)
                                                #((m4559 top))
                                                 (list '#(syntax-object
                                                          cons
                                                          ((top)
+                                                          #(ribcage () () ())
                                                           #(ribcage
                                                             #(#{\ g4578}#
                                                               #{\ g4577}#)
                                            (cons '#(syntax-object
                                                     append
                                                     ((top)
+                                                     #(ribcage () () ())
                                                      #(ribcage
                                                        #(#{\ g4590}#)
                                                        #((m4591 top))
                                                (cons '#(syntax-object
                                                         vector
                                                         ((top)
+                                                         #(ribcage () () ())
                                                          #(ribcage
                                                            #(#{\ g4602}#)
                                                            #((m4603 top))
                                              (list '#(syntax-object
                                                       list->vector
                                                       ((top)
+                                                       #(ribcage () () ())
                                                        #(ribcage
                                                          #(#{\ g4614}#)
                                                          #((m4615 top))
                                   (cons '#(syntax-object
                                            begin
                                            ((top)
+                                            #(ribcage () () ())
                                             #(ribcage
                                               #(exp)
                                               #((top))
                         (list '#(syntax-object
                                  include
                                  ((top)
+                                  #(ribcage () () ())
                                   #(ribcage #(fn) #((top)) #("i4671"))
                                   #(ribcage () () ())
                                   #(ribcage () () ())
                                                            #("i4726"
                                                              "i4727"
                                                              "i4728"))
+                                                         #(ribcage () () ())
                                                          #(ribcage
                                                            #(rest)
                                                            #((top))
                                                                  #("i4726"
                                                                    "i4727"
                                                                    "i4728"))
+                                                               #(ribcage
+                                                                 ()
+                                                                 ()
+                                                                 ())
                                                                #(ribcage
                                                                  #(rest)
                                                                  #((top))
                                                                  #("i4726"
                                                                    "i4727"
                                                                    "i4728"))
+                                                               #(ribcage
+                                                                 ()
+                                                                 ()
+                                                                 ())
                                                                #(ribcage
                                                                  #(rest)
                                                                  #((top))
                                                                        #("i4726"
                                                                          "i4727"
                                                                          "i4728"))
+                                                                     #(ribcage
+                                                                       ()
+                                                                       ()
+                                                                       ())
                                                                      #(ribcage
                                                                        #(rest)
                                                                        #((top))
                                                                  #("i4726"
                                                                    "i4727"
                                                                    "i4728"))
+                                                               #(ribcage
+                                                                 ()
+                                                                 ()
+                                                                 ())
                                                                #(ribcage
                                                                  #(rest)
                                                                  #((top))
                     (list '#(syntax-object
                              let
                              ((top)
+                              #(ribcage () () ())
                               #(ribcage #(body) #((top)) #("i4693"))
                               #(ribcage
                                 #(e m1 m2)
                           (list (list '#(syntax-object
                                          t
                                          ((top)
+                                          #(ribcage () () ())
                                           #(ribcage
                                             #(body)
                                             #((top))
index f5a7305b6e31a94eb66a381052fdcf2a56077b29..4266400957cf621ee2ce5aab27b52427b5be11d3 100644 (file)
    (lambda (x)
       (syntax-case x ()
          ((_ () e1 e2 ...)
-          #'(begin e1 e2 ...))
+          #'(let () e1 e2 ...))
          ((_ ((out in)) e1 e2 ...)
-          #'(syntax-case in () (out (begin e1 e2 ...))))
+          #'(syntax-case in ()
+              (out (let () e1 e2 ...))))
          ((_ ((out in) ...) e1 e2 ...)
           #'(syntax-case (list in ...) ()
-              ((out ...) (begin e1 e2 ...)))))))
+              ((out ...) (let () e1 e2 ...)))))))
 
 (define-syntax syntax-rules
   (lambda (x)
index 84f1cfc8ba1e3556e4251f48503f10c3ff76dc17..6183df8138a29babe02341d1d743bfa90703fe56 100644 (file)
     ((alist ((key val) ...))
      (list '(key . val) ...))))
 
+(with-test-prefix "with-syntax"
+  (pass-if "definitions allowed in body"
+    (equal? (with-syntax ((a 23))
+              (define b #'a)
+              (syntax->datum b))
+            23)))
+
 (with-test-prefix "tail patterns"
   (with-test-prefix "at the outermost level"
     (pass-if "non-tail invocation"