|
|
|
|
|
by svat
829 days ago
|
|
In what way does it break down? Maybe if one is thinking of boxes, going by "a change to the value of a"? The book says: > When a binding points at a value, that does not mean it is tied to that value forever. The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one In this case: let a = 22;
The binding a points to the value 22. let b = a;
The binding b points to the same value that a points to, namely 22. a = 23;
The binding a now points to a different value 23. The binding b is not affected.I've linked it a few times in this thread, but see the equivalent article for Python, which explains it clearly: https://nedbatchelder.com/text/names1.html (It cannot break down because it's how the language works.) |
|
This is exactly what I’m talking about:
> The binding b points to the same value that a points to
It may look obvious to you, but someone will interpret “the same value” as literally the same. So they might expect a change in a to reflect on b. Whereas if you tell them the “a box contains 22” and “the b box also contains 22” you prevent that misunderstanding. They might not have any concept of references/pointers yet and are just trying to make sense out of everything. These are the kind of silly mistakes people make when learning programming, or a new language.
It’s not about being right or wrong but providing a safe path to understanding that can be built upon. I did not mean the binding/tentacle abstraction is wrong, just that there might be a simpler one to introduce the concept. The book is still great regardless.