News for hackers. Stuff that matters.
Re:John Carmack on Mutable Variables by dwwoelfel on Friday October 31, 2025 @11:53AM (#45773479)
Carmack is talking about variable reassignment here, which Clojure will happily let you mutate.

For example:

  (let [result {:a 1}
        result (assoc result :b 2)]
    ...)

He mentions that C and C++ allow const variables, but Clojure doesn't support that.

clj-kondo has a :shadowed-var rule, but it will only find cases where you shadow a top-level var (not the case in my example).

Re:John Carmack on Mutable Variables by didibus on Friday October 31, 2025 @12:32PM (#45773913)
It's more nuanced, because the shadowing is block-local, so when the lexical scope exits the prior bindings are restored.

I think in practice this is the ideal middle ground of convenience (putting version numbers at the end of variables being annoying), but retaining mostly sane semantics and reuse of prior intermediate results.

Re:John Carmack on Mutable Variables by manoDev on Friday October 31, 2025 @12:56PM (#45774145)
That's not mutation though.

The `assoc` on the second binding is returning a new object; you're just shadowing the previous binding name.

This is different than mutation, because if you were to introduce an intermediate binding here, or break this into two `let`s, you could be holding references to both objects {:a 1} and {:a 1 :b 2} at any time in a consistent way - including in a future/promise dereferenced later.

Re:John Carmack on Mutable Variables by potetm on Friday October 31, 2025 @10:05PM (#45778688)
regardless of the mechanism, you still run into the exact same problem John had.