summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-11-22 18:36:58 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-11-22 18:36:58 +0100
commit116e3cab66eb8d9d09aca20310a01f544848b7fa (patch)
tree73607acdb6aeeb3ac712bbf8e391dc94e57dea32
parentaff9a08de8df4d050ff0bcb007c25dcb30997327 (diff)
downloadmew-116e3cab66eb8d9d09aca20310a01f544848b7fa.tar.gz
mew-116e3cab66eb8d9d09aca20310a01f544848b7fa.tar.xz
mew-116e3cab66eb8d9d09aca20310a01f544848b7fa.zip
add =>*
-rw-r--r--mew.scm8
-rw-r--r--mew.svnwiki4
-rw-r--r--tests/test.mew5
3 files changed, 16 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm
index 97ff476..bc03f6d 100644
--- a/mew.scm
+++ b/mew.scm
@@ -26,7 +26,7 @@
      -> fun-> fun->> set->
      =? <>?
      ~?
-     => and=> set=>
+     => =>* and=> set=>
 
      generic-make-accumulator)
 
@@ -850,6 +850,12 @@
 
   (define => act)
 
+  (define-syntax =>*
+    (syntax-rules ()
+      ((_ expr . fs)
+       (receive args expr
+         (apply (per . fs) args)))))
+
   (define-syntax set=>
     (syntax-rules ()
       ((_ location . fs)
diff --git a/mew.svnwiki b/mew.svnwiki
index 7fd2d57..09c6d86 100644
--- a/mew.svnwiki
+++ b/mew.svnwiki
@@ -211,6 +211,10 @@ Reverse function compose all {{<fun>}}, then apply to {{<obj>}}.
 
 Alias for {{act}}.
 
+<syntax>(=>* <form> <fun>...)</syntax>
+
+Like {{=>}}, but {{<form>}} may return multiple values.
+
 <syntax>(set=> <loc> <fun>...)</set>
 
 Shortcut for {{(set <loc> (=> <loc> <fun>...))}}.
diff --git a/tests/test.mew b/tests/test.mew
index 9220312..904059d 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -478,6 +478,11 @@
   (test 43 (=> '(6 7) (op apply * _) inc))
   (test 42 (=> 42)))
 
+(test-group "=>*"
+  (test 42 (=>* (values 6 7) * dec inc))
+  (test '(6 7) (receive (=>* (values 6 7))))
+  (test '(7 6) (receive (=>* (values 6 7) (proj 1 0)))))
+
 (test-group "set=>"
   (test 42 (seq
              (def x 40)