squint

Patrick 2025-03-18T21:09:52.964639Z

Hey y'all! I was wondering if it's possible to make variables defined in let blocks mutable? I'm currently using this little workaround but I'm hoping there's a better way

(let [data {:drawdata []
             :linenum 0
             :workinglen 500}        
       lineheight 20]
   (set! (.-linenum data) 1))

borkdude 2025-03-18T21:18:28.193879Z

By design they are not mutable, this is against Clojure's design. If you need mutability, you can indeed use a mutable object, or an atom

Patrick 2025-03-18T21:19:23.720219Z

Makes sense. Wasn't sure if there was a reader macro or something. Thank you!

👍 1
borkdude 2025-03-18T21:20:11.998369Z

Glad to help. If you're making something cool with squint, please share :)