From 57cd9b595620102abe43fb486ed7d379d5a50ce0 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Tue, 13 Oct 2026 07:59:49 +0200 Subject: [PATCH] csys: rename gen-proc special actions, now: prepare, finalize; minor improvements --- csys/csys.lisp | 8 ++++---- csys/environ.lisp | 2 +- storage/storage.lisp | 5 +---- test/test-csys.lisp | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index 68525f1..e4a0dcc 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -105,11 +105,11 @@ (defun merge-actions (&optional act+ (base (basic-actions))) (util:plist-merge base act+)) -(defun gen-proc (actions &key default before after) +(defun gen-proc (actions &key default prepare finalize) (lambda (msg scope) (let* ((key (message:action msg)) (acts (getf actions key (getf actions :default default)))) - (dolist (act (alx:flatten (cons before (cons acts (list after))))) + (dolist (act (alx:flatten (list prepare acts finalize))) (when act (util:mv-bind (nmsg (nscope scope)) (funcall act msg scope) (setf msg nmsg scope nscope))))) @@ -118,7 +118,7 @@ (defun std-proc (&rest args &key actions &allow-other-keys) (let ((actions (or actions (merge-actions args)))) (gen-proc actions - :after (lambda (msg scope) (forward msg scope))))) + :finalize (lambda (msg scope) (forward msg scope))))) (defun eff-proc (&rest args &key actions &allow-other-keys) (let ((actions (or actions (merge-actions args)))) @@ -127,7 +127,7 @@ (setf (nth 1 (shape:head msg)) :effect) (forward msg scope) (unless (syns scope) (notify msg scope))))) - (gen-proc actions :after #'forward-eff)))) + (gen-proc actions :finalize #'forward-eff)))) (defun forward (msg scope) (when msg diff --git a/csys/environ.lisp b/csys/environ.lisp index aa0d9b7..23ae377 100644 --- a/csys/environ.lisp +++ b/csys/environ.lisp @@ -40,7 +40,7 @@ (defun simple-proc (msg scope) (csys:gen-proc (actions) - :after (lambda (msg scope) (actor:send (csys:environ scope) msg)))) + :finalize (lambda (msg scope) (actor:send (csys:environ scope) msg)))) ;;;; eff contact cells diff --git a/storage/storage.lisp b/storage/storage.lisp index ff31e57..b6b5fe9 100644 --- a/storage/storage.lisp +++ b/storage/storage.lisp @@ -84,10 +84,7 @@ ;;;; utilities (defun normalize-plist (pl) - (let ((res nil)) - (alx:doplist (k v pl res) - (push v res) - (push (util:to-keyword k) res)))) + (util:loop-plist pl k v nconc (list (util:to-keyword k) v))) (defun ts-string (ts) (format nil "~a" (local-time:universal-to-timestamp ts))) diff --git a/test/test-csys.lisp b/test/test-csys.lisp index aa810b3..dcdd72d 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -44,7 +44,7 @@ (let* ((t:*test-suite* (csys:environ scope)) (proc (csys:gen-proc (environ:actions) - :after (lambda (msg scope) + :finalize (lambda (msg scope) (when msg (actor:send (core:mailbox (tc:receiver t:*test-suite*)) msg)))))) (funcall proc msg scope)))