This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-03-21
Channels
- # announcements (1)
- # architecture (392)
- # babashka (3)
- # beginners (1)
- # calva (2)
- # cider (1)
- # clojure (30)
- # clojure-denmark (2)
- # clojure-dev (9)
- # clojure-europe (13)
- # clojure-italy (2)
- # clojure-japan (17)
- # clojure-korea (8)
- # clojure-nl (1)
- # clojure-norway (74)
- # clojure-uk (3)
- # clojurescript (6)
- # code-reviews (8)
- # conjure (1)
- # data-science (1)
- # datascript (7)
- # datomic (1)
- # fulcro (1)
- # graalvm (9)
- # humbleui (3)
- # hyperfiddle (11)
- # leiningen (4)
- # lsp (7)
- # malli (7)
- # off-topic (57)
- # other-languages (9)
- # overtone (7)
- # shadow-cljs (30)
- # sql (15)
- # squint (3)
- # timbre (3)
- # vim (6)
Because mutability...
Yeah, actually this post triggered me: https://clojurians.slack.com/archives/C03A6GE8D32/p1710956328696939?thread_ts=1710955729.886189&cid=C03A6GE8D32
I work in a JS codebase as well as a Clojure codebase at work. The JS code uses Immutable.js (and React/Redux) but I still trip over mutability sometimes and I stare at the code and think "WTF?" ... and then I realize "Oh, darn, that modifies the object I'm holding 😞 "
sort on arrays in js mutates the original -- completely unforgivable
that and reverse
Interestingly, it's not what happens in SuperCollider:
(
x = [] ! 4;
x.at(0).add(\WAT);
x;
)
-> [ [ WAT ], [ ], [ ], [ ]
Probably, the []
has an implicit function call in it, so that it's a new instance everytime.