util:mv-bind: additional return values are always declared optional

This commit is contained in:
Helmut Merz 2026-07-23 11:43:11 +02:00
parent 2d30776e81
commit 62fb5f883d
4 changed files with 7 additions and 6 deletions

View file

@ -74,13 +74,13 @@
(lambda (msg) (funcall (proc scope) msg scope))) (lambda (msg) (funcall (proc scope) msg scope)))
(defun std-proc (msg scope &key (default #'remember) params actions) (defun std-proc (msg scope &key (default #'remember) params actions)
(util:mv-bind (nmsg &optional (nscope scope)) (util:mv-bind (nmsg (nscope scope))
(handle-action msg scope :default default :actions actions :params params) (handle-action msg scope :default default :actions actions :params params)
(forward nmsg (syns nscope)) (forward nmsg (syns nscope))
(update nscope))) (update nscope)))
(defun eff-proc (msg scope &key params actions) (defun eff-proc (msg scope &key params actions)
(util:mv-bind (nmsg &optional (nscope scope)) (util:mv-bind (nmsg (nscope scope))
(handle-action msg scope :default #'no-op :actions actions :params params) (handle-action msg scope :default #'no-op :actions actions :params params)
(notify nmsg nscope) (notify nmsg nscope)
(update nscope))) (update nscope)))

View file

@ -99,10 +99,10 @@
(let ((pl '(:a 0))) (let ((pl '(:a 0)))
(== (util:plist-add pl :b 1) '(:b 1 :a 0)) (== (util:plist-add pl :b 1) '(:b 1 :a 0))
(== pl '(:b 1 :a 0))) (== pl '(:b 1 :a 0)))
(util:mv-bind (a &optional (b :not-set) (c :not-set)) (values 42 2) (util:mv-bind (a (b :not-set) c) (values 42 2)
(== a 42) (== a 42)
(== b 2) (== b 2)
(== c :not-set)) (== c nil))
(util:load-dotenv (t:test-path ".test.env")) (util:load-dotenv (t:test-path ".test.env"))
(== (util:getenv "SCOPES_USER") "user-from-env-file") (== (util:getenv "SCOPES_USER") "user-from-env-file")
(== (util:getenv "SCOPES_PASSWORD") "very_secret")) (== (util:getenv "SCOPES_PASSWORD") "very_secret"))

View file

@ -36,7 +36,7 @@
(defun proc-env (msg scope) (defun proc-env (msg scope)
(let ((t:*test-suite* (csys:environ scope))) (let ((t:*test-suite* (csys:environ scope)))
(util:mv-bind (nmsg &optional (scope scope)) (util:mv-bind (nmsg (scope scope))
(csys:handle-action msg scope :actions (environ:actions)) (csys:handle-action msg scope :actions (environ:actions))
(util:lgi nmsg (tc:receiver t:*test-suite*)) (util:lgi nmsg (tc:receiver t:*test-suite*))
(actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg)))) (actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg))))

View file

@ -99,7 +99,8 @@
`(setf ,pl (cons ,k (cons ,v ,pl)))) `(setf ,pl (cons ,k (cons ,v ,pl))))
(defmacro mv-bind (vars vform &body body) (defmacro mv-bind (vars vform &body body)
`(destructuring-bind ,vars (multiple-value-list ,vform) ,@body)) `(destructuring-bind ,(cons (car vars) (cons '&optional (cdr vars)))
(multiple-value-list ,vform) ,@body))
;;;; strings, symbols, keywords, ... ;;;; strings, symbols, keywords, ...