git » homepage.git » commit b75018f

Compare with-local-vars and volatile storage in the introduction

author Alan Dipert
2026-11-13 01:14:41 UTC
committer Alan Dipert
2026-11-13 01:14:41 UTC
parent 4dd4dd210bf21a11450f389d517997feb07a6cc3

Compare with-local-vars and volatile storage in the introduction

md/Lisp/MutableLocals.md +6 -1

diff --git a/md/Lisp/MutableLocals.md b/md/Lisp/MutableLocals.md
index eb37e0c..1a3bb78 100644
--- a/md/Lisp/MutableLocals.md
+++ b/md/Lisp/MutableLocals.md
@@ -21,7 +21,12 @@ Here's an example using `loophole`, a macro provided by my Clojure library, [Bla
 ;; => 4
 ```
 
-Clojure has [`with-local-vars`](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/with-local-vars) for mutable local state, but reads and writes look up thread-local Var bindings, and primitive numbers are boxed. I'd like to use ordinary JVM locals and keep primitive arithmetic where possible.
+Clojure already offers mutable storage:
+
+- [`with-local-vars`](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/with-local-vars) uses thread-local Vars, with binding lookups and boxed primitive numbers.
+- [`volatile!`](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/volatile!) provides a simpler mutable cell, but primitive numbers are still boxed for storage.
+
+I'd like to use ordinary JVM locals and keep primitive arithmetic where possible.
 
 Clojure already updates [JVM local-variable slots](https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-2.html#jvms-2.6.1) to implement `loop` and `recur`. We can use the same mechanism for our own variables.