3 ms·
You don't want to store reference counts in pointers. The reference count of a heap-allocated object is a property of that object, and not of the pointer. The
by kazinator 4y ago
You don't want to store reference counts in pointers. The reference count of a heap-allocated object is a property of that object, and not of the pointer.
The pointer gets copied; the object does not. You're going to end up with copies of the pointer which have different reference counts, not knowing which one is the real one.
As a rule of thumb, no mutable property of the heap object should be forwarded into the pointer word used to reference it.
Not sure where the author is going with all that.
Edit: it may work if these pointers are handles in a table, which seems to be what the article is getting at. The actual value representation points or indexes into the table and those are passed around.
So the table is just a very compact way to store objects in a single pointer-sized word.