From 6e86ea3f962577dca6f5ce703ab22e0ad2390d2b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 13 May 2021 11:00:16 +0200 Subject: Avoid mutation of state objects by "set-state-name!" --- guile/starlet/scanout.scm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'guile/starlet/scanout.scm') diff --git a/guile/starlet/scanout.scm b/guile/starlet/scanout.scm index 7833076..e7ab623 100644 --- a/guile/starlet/scanout.scm +++ b/guile/starlet/scanout.scm @@ -41,6 +41,21 @@ ;; List of states being scanned out (define state-list (make-atomic-box '())) +;; Association list of names to states +(define state-names (make-atomic-box '())) + + +(define (get-state-name st) + (assq-ref (atomic-box-ref state-names) + st)) + + +(define (set-state-name! st name) + (atomic-box-set! state-names + (assq-set! (atomic-box-ref state-names) + st + name))) + ;; Patch a new fixture (define* (patch-real name -- cgit v1.2.3