message, csys: functions for accessing action and object keys in message heads

This commit is contained in:
Helmut Merz 2026-04-07 08:10:47 +02:00
parent 90fad03268
commit 429634dd82
2 changed files with 12 additions and 5 deletions

View file

@ -6,7 +6,7 @@
(:shape :scopes/shape)
(:util :scopes/util))
(:export #:message-meta #:message #:create
#:head #:data))
#:action-key #:object-key))
(in-package :scopes/core/message)
@ -28,3 +28,12 @@
(defmethod actor:content ((msg message))
(list (shape:head-plist msg) (shape:data msg)))
(defun action-key (msg)
(let ((head (shape:head msg)))
(list (car head) (cadr head))))
(defun object-key (msg)
(let ((head (shape:head msg)))
(cons (car head) (cddr head))))

View file

@ -81,8 +81,7 @@
(actor:send sn msg)))
(defun find-sensors (msg)
(let* ((head (shape:head msg))
(key (cons (car head) (cddr head)))
(let* ((key (message:object-key msg))
(sns (gethash key (sensors *environment*))))
;(util:lgi key sns *environment*)
sns))
@ -99,8 +98,7 @@
(funcall s msg)))
(defun handle-action (msg state syns &key (default #'no-op))
(let* ((head (shape:head msg))
(key (list (car head) (cadr head)))
(let* ((key (message:action-key msg))
(act (gethash key (actions *environment*) default)))
(funcall act msg state syns)))