On Sunday, 13 January 2013 at 00:56:59 UTC, Charles Hixson wrote:
I don't think reference counting would work for my purposes, which is why I wanted a "weak pointer". There will usually be many live references at the time I need to release an item. If I'd had weak pointers I could have made almost all of them weak pointers. I want to release things that are stale, not things that are unreferenced. I was trying to avoid needing to cycle through the entire data structure.

Just off hand I think I'm recalling that in C++ the weak pointers were related and part of the main reference counting; An allocated (heap) control block handled the references and memory. If then you were to extended a second number to represent weak pointers, they would be for when the control block could free itself (vs the data with the strong pointers).

But the GC wouldn't be part of it most likely unless the control block itself was leaked in it's entirety. That might be safe (mostly); In those cases you'd have to test the control block which would tell you if the pointer was still valid or not.

Well I got my hands full so I won't be the to touch this possible implementation; At least for a while.

Reply via email to