Great article, I especially like the call out to use const
where ever possible; I make the same recommendation whenever I’m helping in order to make the code more robust.
Is it possible that you introduced an additional level of indirection that doesn’t actually exist? My understanding is that a variable is always just a label for a given memory address and the address it refers to doesn’t change. When you assign to a variable, you’re simply overwriting the value stored at that address, not changing what address the variable refers to. As you pointed out, primitive values can be stored directly in that memory location, while non-primitives are stored elsewhere and their address is stored in the variable’s associated memory location.