Hacker News new | ask | show | jobs
by IshKebab 1040 days ago
The references are not immutable in this case.
1 comments

A reference, unlike a pointer, always points to the same memory address(*); so the reference is immutable even if the cell contents it points to are not. That's the difference between a reference and a pointer, by definition; not just the different syntax.

Back in the day, that was one of the major selling points of the new language Java over the more common C and C++. Developers don't learn about it nowadays because changing pointers is practically never done outside the most esoteric parts of system programming.

(*) Semantically, at least. The compiler is free to relocate the value to a different memory position in a way transparent to the programmer.

Ah, not the pointer problems I thought they were talking about...