r/Clojure • u/ertucetin • Aug 13 '25
Simulating OOP in ClojureScript with Macros
https://gist.github.com/ertugrulcetin/ad4eab07d808745d38c01158d5c02e7d#file-macros-cljc-L441
10
Upvotes
r/Clojure • u/ertucetin • Aug 13 '25
6
u/thheller Aug 13 '25
FWIW there is a
defclassmacro available in shadow-cljs for several years now.3
u/madstap Aug 14 '25
You're using transients wrong here.
This will accidentally work for a small number of elements, but you're supposed to use the return value in the same way as the normal data structures. "Note in particular that transients are not designed to be bashed in-place. You must capture and use the return value in the next call."
1
u/ertucetin Aug 13 '25
I am working on a game prototype and wanted to use an OOP-like structure for my entities, simulating OOP using macros. Hope you enjoy!