Hi folks!
Frank Heckenbach wrote:
What about the following situation:
Create an object Foo (store pointer) and an object Bar that points to Foo (i.e., contains the store pointer).
Create an object Baz that also points to Foo (reference pointer).
Destroy Bar. IIUIC, Foo will be disposed of and the reference pointer in Baz invalidated. That's nice so I get an error message rather than a crash when I try to access Baz.Foo, but I'd prefer to actually access it. ;-)
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.
I guess I must be missing something, since that's only a very simple example of what happens all the time in GCC/GPC.
It's a simple process happening all the time, yes, that's the point; that's why I think a standard solution could pay.
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...
These are memory and runtime issues, and given that copying pointers is quite common in GPC, these effects must be analyzed precisely.
Agreed.
Except that you are forced to think before you code.;-)
As I said in another mail, polemics probably won't get us any further.
Didn't intend to be polemic, Frank... My statement was just an example of self-observation. ;-)
Not "giving up control" can also mean not delegating work. There are certainly situations where you want exact control about when and how some block of memory is disposed of, and I also don't view GC as a panacea.
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.
Markus