Markus Gerwinski wrote:
The point is: If in the current state you have n pointers p1 ... pn pointing to the same data, and p1 is disposed, p2 ... pn still point to the disposed address, and you don't have any possibility to check whether the data is valid anymore. "store" and "reference" pointers would just yield this additional possibility to check. Currently, it's what I'm implementing by hand in all of my Pascal programs; delegating it to the compiler would help to avoid crashes and memory leaks.
OK, this is more a debugging aid (i.e., the program will probably run slower, but you find bug faster). It doesn't solve the original problem (with "tree" structures), but is certainly useful for other purposes.
Though I'm not sure why the distinction between store and reference pointers is necessary. Why not make all pointers the same, and when one pointer to an object is disposed of, all the other ones are invalidated?
Besides, when you really want to evaluate things, you have to describe all the hidden costs first. AFAICS, for every object you need an implicit list containing all the reference pointers, so they can be invalidated later.
Depends on the way how to implement it...
Now I'm interested how else you'd implement it. An alternative I could think of are double-pointers, but these are slower to dereference and cause another kind of memory leak: Each second-level pointer allocated once can never be freed if you don't know if there's somewhere a first-level pointer pointing to it. I suppose that's not what you have it mind.
If we're not going to make GC obligatory and drop any other way of pointer deallocation (The @#*!-"don't let the programmer ever touch memory"- philosophy of Java)-:, I'm okay with it.
OK, apparently you also had the misunderstanding that this was about the MM for Pascal programs. As you've probably read in my other mails by now, Russ's original mail was about GCC/GPC's internal MM.
Frank