From 7c78f1df2f730f014f00fc490fbcc051ec28546a Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Mon, 20 Jul 2026 10:50:08 +0200 Subject: [PATCH] csys: scope creation: fixes and improvements --- csys/csys.lisp | 19 ++++++++++--------- csys/environ.lisp | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/csys/csys.lisp b/csys/csys.lisp index 581de4f..a8ea3bf 100644 --- a/csys/csys.lisp +++ b/csys/csys.lisp @@ -9,7 +9,7 @@ (:util :scopes/util) (:alx :alexandria)) (:export #:scope #:environ - #:make-prog + #:make-program #:neuron #:std-proc #:create #:handle-action #:notify)) @@ -22,31 +22,32 @@ ((value :accessor value :initarg :value :initform 0) ;(params :accessor params :initarg :params :initform nil) ; <- program (categ :accessor categ :initarg :categ :initform '(:csys :c00)) - (stage :accessor stage :initform :initial) - (proc :accessor proc :initarg :proc :initform #'std-proc) - (program :reader program :initarg :program :initform nil) + (stage :accessor stage :initarg :stage :initform :initial) + (proc :accessor proc) + (program :reader program :initarg :program) ;(actions :accessor actions :initarg :actions :initform nil) ; <- program (syns :accessor syns :initform nil) (environ :reader environ :initarg :environ))) -(defun scope (program &rest args &key (cls 'scope) &allow-other-keys) +(defun scope (prg env &rest args &key (cls 'scope) &allow-other-keys) (remf args :cls) - (apply #'make-instance cls :program program args)) + (apply #'make-instance cls :program prg :environ env args)) (defmethod initialize-instance :after ((sc scope) &key &allow-other-keys) (set-proc sc)) (defun reset-scope (scope &rest args) - (apply #'scope (or (getf args :program) (program scope)) + (apply #'scope + (getf args :program) (program scope) + (getf args :environ (environ scope)) :categ (getf args :categ (categ scope)) - :environ (getf args :environ (environ scope)) args)) (defun set-proc (scope) (setf (proc scope) (funcall (program scope) scope)) scope) -(defgeneric make-prog (spec) +(defgeneric make-program (spec) (:method ((fn function)) (lambda (scope) fn))) ;;;; neurons (= async tasks) and synapses (= connections) diff --git a/csys/environ.lisp b/csys/environ.lisp index 4801ef1..93bde02 100644 --- a/csys/environ.lisp +++ b/csys/environ.lisp @@ -17,8 +17,8 @@ ((cells :reader cells :initform (make-hash-table :test #'equal)))) (defun create (proc app) - (let ((prog (csys:make-prog proc))) - (csys:neuron (csys:scope prog :cls 'scope :environ app)))) + (let ((prog (csys:make-program proc))) + (csys:neuron (csys:scope prog app :cls 'scope :categ '(:env :c00))))) ;;;; action handlers, public callables