prepare for additional functionality; step 1: simple numeric messages

This commit is contained in:
Helmut Merz 2025-06-06 20:36:41 +02:00
parent b86ea21e3c
commit 871c5ef5af
2 changed files with 9 additions and 6 deletions

View file

@ -6,7 +6,8 @@
(:util :scopes/util)) (:util :scopes/util))
(:export #:neuron #:synapse (:export #:neuron #:synapse
#:forward #:forward
#:set-content)) #:set-content
#:inhibit))
(in-package :decons/csys) (in-package :decons/csys)
@ -24,9 +25,9 @@
(dolist (s syns) (dolist (s syns)
(funcall s msg))) (funcall s msg)))
;;;; helpers for operating on messages ;;;; helpers for operations on complex messages (with content and customer slots)
(defun set-content (fn) (defun set-content (fn)
(lambda (msg) (actor:message (lambda (msg) (actor:set-content msg fn)))
(funcall fn (actor:content msg))
(actor:customer msg)))) (defun inhibit () (set-content #'-))

View file

@ -10,7 +10,9 @@
(deftest test-neuron () (deftest test-neuron ()
(let* ((prb (csys:neuron #'probe :env t:*test-suite* :state '(43 44))) (let* ((prb (csys:neuron #'probe :env t:*test-suite* :state '(43 44)))
(syn (csys:synapse prb (csys:set-content (lambda (c) (+ 1 c))))) ;(syn (csys:synapse prb (csys:set-content #'1+)))
(syn (csys:synapse prb #'1+))
;(syn (csys:synapse prb (csys:inhibit)))
(fw (csys:neuron #'csys:forward :syns (list syn)))) (fw (csys:neuron #'csys:forward :syns (list syn))))
(actor:send fw 42) (actor:send fw 42)
(actor:send fw 43) (actor:send fw 43)