Overview Clamps Packages CM Dictionary Clamps Dictionary Fomus
Next: all-notes-off , Previous: add-trigger-fn , Up: A , Home: Overview

Clamps Dictionary

add-watch

Macro

(add-watch unwatch &rest forms)

Add function bodies in forms to unwatch.

Arguments

unwatch A list containing functions to undo a watch definition.
forms Zero or more function bodies supplied to the #'watch function.

Example

(defparameter *unwatch* nil)
(defparameter *v1* (make-ref 0.0))
(defparameter *v2* (make-ref 0.0))

(add-watch
 *unwatch*
 (format t "~&v1 changed: ~a" (get-val *v1*))
 (format t "~&v2 changed: ~a" (get-val *v2*)))
;; => (#<function (lambda () :in watch) {120DE2BB8B}>
;;     #<function (lambda () :in watch) {120DE2BAEB}>)
;;
;; Output in REPL:
;; v1 changed: 0.0
;; v2 changed: 0.0

(set-val *v1* 0)
;; => 20
;;
;; Output in REPL:
;; v1 changed: 0.0

(set-val *v2* -2.3)
;; => -2.3
;;
;; Output in REPL:
;; v2 changed: -2.3

(unwatch-all *unwatch*)

*unwatch* ; => nil

(set-val *v1* 0)
;; => 0
;;
;; No Output in REPL.

See also

Author: Orm Finnendahl

Created: 2025-08-05 Di 20:46

Validate