summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-11-03 20:06:54 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-11-03 20:06:54 +0100
commit7a469b8d057464a1953f6b02b36ea3d5626c42fa (patch)
treee267979a45342055dd0be8b247962e543a13c842
parenteed472a7436d2029c30799274545243f0ccd725d (diff)
downloadmew-7a469b8d057464a1953f6b02b36ea3d5626c42fa.tar.gz
mew-7a469b8d057464a1953f6b02b36ea3d5626c42fa.tar.xz
mew-7a469b8d057464a1953f6b02b36ea3d5626c42fa.zip
make rep use the binding syntax of loc
-rw-r--r--mew.el2
-rw-r--r--mew.scm11
-rw-r--r--mew.svnwiki6
-rw-r--r--tests/test.mew2
4 files changed, 15 insertions, 6 deletions
diff --git a/mew.el b/mew.el
index baaedc9..db1faea 100644
--- a/mew.el
+++ b/mew.el
@@ -4,7 +4,7 @@
 (put 'fun 'scheme-indent-function 1)
 (put 'loc 'scheme-indent-function 1)
 (put 'rec 'scheme-indent-function 1)
-(put 'rep 'scheme-indent-function 'scheme-let-indent)
+(put 'rep 'scheme-indent-function 2)
 (put 'seq 'scheme-indent-function 0)
 
 (put 'if 'scheme-indent-function 1)
diff --git a/mew.scm b/mew.scm
index 053ad98..f4537c0 100644
--- a/mew.scm
+++ b/mew.scm
@@ -191,10 +191,17 @@
                          (,(rename append) ... (,(rename list) ,@y))))
               ))))))
 
+  (define-syntax rep-internal
+    (syntax-rules ()
+      ((_ (bindings ...) name () (body ...))
+       (let name (bindings ...) body ...))
+      ((_ (bindings ...) name (x y brest ...) body)
+       (rep-internal (bindings ... (x y)) name (brest ...) body))))
+
   (define-syntax rep
     (syntax-rules ()
-      ((_ name ((var val) ...) body ...)
-       (let name ((var val) ...) body ...))))
+      ((_ name (bindings ...) body ...)
+       (rep-internal () name (bindings ...) (body ...)))))
 
   (define-syntax while
     (syntax-rules ()
diff --git a/mew.svnwiki b/mew.svnwiki
index 7255aaf..6a14d79 100644
--- a/mew.svnwiki
+++ b/mew.svnwiki
@@ -94,9 +94,11 @@ used a non-local exit (as from {{esc}}).
 Returns value of {{<body>}}, so can also be used as a replacment
 for Common Lisp PROG1.
 
-<syntax>(rep <name> ((<var> <init>) ...) <body>)</syntax>
+<syntax>(rep <name> (<var1> <init1> ... <varN> <initN>) <body>...)</syntax>
 
-Explicit form of named let.
+Explicit form of named {{let}}, using {{loc}} binding syntax.
+
+Assignments cannot refer to previously assigned values of the {{rep}}.
 
 <syntax>(seq . <body>)</syntax>
 
diff --git a/tests/test.mew b/tests/test.mew
index 03f67c7..7b6f463 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -167,7 +167,7 @@
   (test 42 ((op* * 2 ... 3) 7)))
 
 (test-group "rep"
-  (test 42 (rep loop ((x 27) (y 5))
+  (test 42 (rep loop (x 27 y 5)
               (if (> y 0)
                 (loop (+ x y) (- y 1))
                 x))))