CBFalconer wrote:
The question is how much overhead to put on pointer dereference. In Pascal, unlike C, we can tell such from VAR dereference through the type system. There is a non-trivial problem involved in passing that knowledge through functional parameters. This can be handled by performing the check at the point of passage, and thenceforce treating as a VAR. Any such mechanism as outlined above depends on intimate knowledge of the actual heap allocation mechanism, and involves overhead. VAR dereference is generated directly by the compiler, and known correct (what is not necessarily known is the validity of an offset, or index, value).
If the actual var parameter is a dereferenced pointer which was disposed meanwhile, even var dereferencing can fail. Of course, disposing a pointer while a reference exists is already invalid, so you could instead try to check at `Dispose' time. But AFAICS, this would require reference counting again, or something like this ...
Frank