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

View file

@ -10,7 +10,9 @@
(deftest test-neuron ()
(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))))
(actor:send fw 42)
(actor:send fw 43)