# HG changeset patch # User Steve Losh # Date 1481755459 18000 # Node ID e9910edd311c017ed55502d29e8e8f2fd51ee61c # Parent fd8c40ec26ee9896d30719fc9936aa4a2264ca65 Add `multiple-value-bind*` diff -r fd8c40ec26ee -r e9910edd311c DOCUMENTATION.markdown --- a/DOCUMENTATION.markdown Wed Dec 14 12:16:13 2016 -0500 +++ b/DOCUMENTATION.markdown Wed Dec 14 17:44:19 2016 -0500 @@ -184,6 +184,27 @@ +### `MULTIPLE-VALUE-BIND*` (macro) + + (MULTIPLE-VALUE-BIND* BINDINGS + &BODY + BODY) + +Bind each pair in `bindings` with `multiple-value-bind` sequentially. + + Example: + + (multiple-value-bind* + (((a b) (values 0 1)) + ((c) (values (1+ b))) + (list a b c)) + ; => + ; (0 1 2) + + From https://github.com/phoe/m-m-v-b + + + ### `RECURSIVELY` (macro) (RECURSIVELY BINDINGS diff -r fd8c40ec26ee -r e9910edd311c losh.lisp --- a/losh.lisp Wed Dec 14 12:16:13 2016 -0500 +++ b/losh.lisp Wed Dec 14 17:44:19 2016 -0500 @@ -471,6 +471,27 @@ (when ,symbol (when-let* ,remaining-bindings ,@body)))))) +(defmacro multiple-value-bind* (bindings &body body) + "Bind each pair in `bindings` with `multiple-value-bind` sequentially. + + Example: + + (multiple-value-bind* + (((a b) (values 0 1)) + ((c) (values (1+ b))) + (list a b c)) + ; => + ; (0 1 2) + + From https://github.com/phoe/m-m-v-b + + " + (if (null bindings) + `(progn ,@body) + (destructuring-bind ((vars form) &rest bindings) bindings + `(multiple-value-bind ,vars ,form + (multiple-value-bind* ,bindings ,@body))))) + ;;;; Mutation ----------------------------------------------------------------- (defun build-zap (place expr env) diff -r fd8c40ec26ee -r e9910edd311c package.lisp --- a/package.lisp Wed Dec 14 12:16:13 2016 -0500 +++ b/package.lisp Wed Dec 14 17:44:19 2016 -0500 @@ -76,7 +76,8 @@ :if-found :gathering :gather - :when-let*)) + :when-let* + :multiple-value-bind*)) (defpackage :losh.mutation (:documentation "Utilities for mutating places in-place.")