#+TITLE: Trivial sensitivities #+author: screwtape * Description Everywhere in his VHDL book, Reichenbacker kept writing #+BEGIN_QUOTE VHDL is a great language for concurrency #+END_QUOTE and I couldn't shake the feeling that he was trying to tell me something. The best I could figure was that when we really are stuck with processing event streams, sensitivities at least make sense. Short story also short, I put sensitivities in ==(getf (symbol-plist symbol) :sensitivities)== which is also setfable (ie you can ==#'push== to it). Finding sensitive symbols is done on a package basis like ==(find-sensitives 'my-sensitivity :my-package)== or it will search 'my-sensitivity's symbol by default by default. If you tangle this file, it will try to put the package into ==~/common-lisp/trivial-sensitivities/==. Exports: | #'find-sensitivities | sensitivity &optional pkg | list | | #'make-sensitive | symbol &rest sensitivities | list | | #'get-sensitivities | symbol | list | | #'remove-sensitivities | symbol &rest sensitivities | list | * ASD #+HEADER: :tangle ~/common-lisp/trivial-sensitivities/trivial-sensitivities.asd #+begin_src lisp (defsystem "trivial-sensitivities" :class :package-inferred-system :depends-on (:trivial-sensitivities/trivialities)) (register-system-packages "trivial-sensitivities/trivialities" '(:trivial-sensitivities)) #+end_src * trivial-sensitivities #+name: trivialities #+HEADER: :tangle ~/common-lisp/trivial-sensitivities/trivialities.lisp #+begin_src lisp (uiop:define-package :trivial-sensitivities (:export #:find-sensitives #:make-sensitive #:get-sensitivities #:remove-sensitivities) (:nicknames :sens)) (in-package :sens) (defun find-sensitives (sensitivity &optional (pkg (symbol-package sensitivity)) &aux (results (list))) (do-symbols (sym pkg) (when (member sensitivity (get-sensitivities sym)) (push sym results))) (values results)) (defun make-sensitive (symbol &rest sensitivities) (setf (getf (symbol-plist symbol) :sensitivities) (append (getf (symbol-plist symbol) :sensitivities) sensitivities))) (defun get-sensitivities (symbol) (getf (symbol-plist symbol) :sensitivities)) (defun remove-sensitivities (symbol &rest remove-sensitivities) (setf (Getf (symbol-plist symbol) :sensitivities) (set-difference (get-sensitivities symbol) remove-sensitivities))) #+end_src