Hacker News new | ask | show | jobs
by kazinator 3219 days ago
For a global def to be a "rebinding" rather than assignment is crippling. It means that previous references to a still see the old thing, which is wrong if you want them to see the new thing.
2 comments

If you want others to see the new thing automatically, you need something much more powerful than plain old assignment anyway: something which will let you pick a synchronization strategy.

"Changes at any arbitrary time, including when you are halfway through reading it" is not in any way a sound synchronization strategy and the only thing you get with assignment.

You seem to understand the important difference between identity (what you see when you read an object) and reference (what you use to access the object). Next important thing on the list is how "reference" cannot just be a pointer to a place in memory -- unless it is immutable.

> you need something much more powerful than plain old assignment anyway: something which will let you pick a synchronization strategy.

Right, just like the king's subjects don't actually need a toaster, but rather breakfast food cooker.

Clojure does not rebind the reference, it just changes it to point to something else. So it does not suffer from what you describe. Previous references will see the new thing as you'd hope.

So def on an existing binding does assignment. That's what is meant by "re-binding".