From 6facc4f22e57049f9dc2b753dd46f0dd60c6786c Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 24 Jul 2026 16:23:52 +0200 Subject: [PATCH] use :effect action as output from effector neuron; action handling improvements --- csys/csys.lisp | 14 ++++++++------ csys/environ.lisp | 6 ++++-- test/test-core.lisp | 1 - test/test-csys.lisp | 6 +++--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index f82d30b..bfc4ec4 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -76,14 +76,14 @@ (defun std-proc (msg scope &key (default #'remember) params actions) (util:mv-bind (nmsg (nscope scope)) (handle-action msg scope :default default :actions actions :params params) - (forward nmsg (syns nscope)) + (when nmsg (forward nmsg (syns nscope))) (update nscope))) (defun eff-proc (msg scope &key params actions) (util:mv-bind (nmsg (nscope scope)) - (handle-action msg scope :default #'no-op :actions actions :params params) - (setf (nth 1 (shape:head nmsg)) :notify) - (notify nmsg nscope) + (handle-action msg scope :default (no-op) :actions actions :params params) + (setf (nth 1 (shape:head nmsg)) :effect) + (when nmsg (notify nmsg nscope)) (update nscope))) (defun create (msg scope) @@ -100,7 +100,7 @@ (dolist (s syns) (funcall s msg))) -(defun handle-action (msg scope &key (default #'no-op) actions params) +(defun handle-action (msg scope &key (default (no-op)) actions params) (let* ((key (message:action msg)) (act (getf actions key (getf actions :default default)))) (apply act msg scope params))) @@ -113,7 +113,9 @@ ;;;; predefined neuron actions -(defun no-op (msg scope) msg) +(defun no-op (&key stop) + (lambda (msg scope) + (unless stop msg))) (defun remember (msg scope) (setf (value scope) (shape:data-value msg :value)) diff --git a/csys/environ.lisp b/csys/environ.lisp index 4c78d8d..39b31e1 100644 --- a/csys/environ.lisp +++ b/csys/environ.lisp @@ -25,8 +25,10 @@ (defun actions () (list :created #'cell-created - :notify #'csys:no-op - :default #'forward)) + :notify (csys:no-op) + :effect (csys:no-op) + :value #'forward + :default (csys:no-op :stop t))) (defun cell-created (msg scope) (let* ((data (shape:data msg)) diff --git a/test/test-core.lisp b/test/test-core.lisp index 648c502..bd9c946 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -37,7 +37,6 @@ (defun check-message (ctx msg) (let ((key (shape:head msg)) (t:*test-suite* (suite ctx))) - (util:lgi (expected ctx)) (multiple-value-bind (val found) (gethash key (expected ctx)) (if found (progn diff --git a/test/test-csys.lisp b/test/test-csys.lisp index 7f55dcc..3d9081c 100644 --- a/test/test-csys.lisp +++ b/test/test-csys.lisp @@ -29,8 +29,8 @@ (defun setup-config () (config:add :test-receiver :setup #'tc:setup) - ;(config:add-action '(:csys :notify :c00 "0-0") (value-in '(1))) - (config:add-action '(:csys :notify) #'tc:check-message) + ;(config:add-action '(:csys :effect :c00 "0-0") (value-in '(1))) + (config:add-action '(:csys :effect) #'tc:check-message) (config:add-action '(:csys) (constantly nil)) ) @@ -68,7 +68,7 @@ (let ((env (setup-test (csys:make-program #'csys:eff-proc))) (rcvr (tc:receiver t:*test-suite*))) (sleep 0.1) - (tc:expect rcvr (message:create '(:csys :notify :c00 "0-0") :data '(:value 1))) + (tc:expect rcvr (message:create '(:csys :effect :c00 "0-0") :data '(:value 1))) (actor:send env (message:create '(:csys :value :c00 "0-0") :data '(:value 1))) (sleep 0.1) (core:shutdown)))