csys: scope creation: fixes and improvements
This commit is contained in:
parent
85c23f10e0
commit
7c78f1df2f
2 changed files with 12 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue