From 62fb5f883d2a9501058a43e5e50fd6315b1b1e00 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Thu, 23 Jul 2026 11:43:11 +0200 Subject: [PATCH] util:mv-bind: additional return values are always declared optional --- csys/csys.lisp | 4 ++-- test/test-core.lisp | 4 ++-- test/test-csys.lisp | 2 +- util/util.lisp | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index 4c16c27..bdbf787 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -74,13 +74,13 @@ (lambda (msg) (funcall (proc scope) msg scope))) (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) (forward nmsg (syns nscope)) (update nscope))) (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) (notify nmsg nscope) (update nscope))) diff --git a/test/test-core.lisp b/test/test-core.lisp index df73109..bd9c946 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -99,10 +99,10 @@ (let ((pl '(:a 0))) (== (util:plist-add pl :b 1) '(: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) (== b 2) - (== c :not-set)) + (== c nil)) (util:load-dotenv (t:test-path ".test.env")) (== (util:getenv "SCOPES_USER") "user-from-env-file") (== (util:getenv "SCOPES_PASSWORD") "very_secret")) diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 7ad7dd5..4e86122 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -36,7 +36,7 @@ (defun proc-env (msg 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)) (util:lgi nmsg (tc:receiver t:*test-suite*)) (actor:send (core:mailbox (tc:receiver t:*test-suite*)) nmsg)))) diff --git a/util/util.lisp b/util/util.lisp index 80add3d..6a080e5 100644 --- a/util/util.lisp +++ b/util/util.lisp @@ -99,7 +99,8 @@ `(setf ,pl (cons ,k (cons ,v ,pl)))) (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, ...