This is a really basic question...
I'm trying to do (set! (.-x acc) 1), but I don't want literally acc.x, x is a parameter passed in.
I understand I should not use aset for this, but I don't know the right way.
I still use goog.object/set (which is the same as aset really, for the generated js but at least it's not using a function in the wrong context)
Ah, that makes sense. I suppose here's where I mention that I'm not using official cljs but rather #squint, so the question might be better asked over there.
would assoc! work in squint ?
Looks like it does! It's specifically defined to operate on objects so it's probably the way to go.
Just in case - another way of doing it in CLJS would be to use unchecked-set. While marked as internal, it's incredibly simple, has been around since forever, and is already used by other projects, so it's extremely unlikely to be changed or removed.
oh nice. that's actually slightly better in this case because it avoids an extra function call.
I wouldn't pay attention to such trifles. :) The VM will do its thing and an extra call of a tiny function will probably not affect anything. If it's in a busy loop and you have doubts, you can always profile it.
stuff like that made a huge difference when I was optimizing my NES emulator. here though the win is just producing cleaner output code, which makes it easier for me to follow in the debugger