summary refs log tree commit diff
diff options
context:
space:
mode:
-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)