I find DanH's way of presenting it more natural (and makes perfect sense now that its been said that way): it *is* allocating something, just not in the heap.  It is requesting new storage for a new object, which might be in the heap, or the stack, or registers. And we might find that new object to be == to an old object, but we're still requesting that space for a new object be allocated.

"new" always creates a new instance but in case of value types, == does not 
allow us see if the instance are different or not.
I'm not sure this is a good way to think value creation, though. It suggests 
that there still *is* an identity there (i.e., the new value has been newly 
allocated), you just can't see it.

I'd rather have programmers think in these terms: when you instantiate a value 
class, you might get an object that already exists. Whether there are copies of 
that object at different memory locations or not is irrelevant—it's still *the 
same object*.

Reply via email to