You take things too seriously, Frank. The wink in reference to GC was a clue that you shouldn't have ... <G>
One of the key advantages of Pascal over more primitive languages, and one of several reasons it is much less bug prone, is that it imposes discipline on the program. IMHO, GC is contrary to that philosophy and not appropriate to Pascal (which is what we are discussing, since we have already established that the GPC compiler needs to use GC to be compatible with GCC-3).
What I was thinking (in the previous message), was that if "double pointers" were not employed for this "store" and "reference" pointer suggestion, then it would be necessary to search the "reference" pointers to find which ones were no longer valid. And I was also thinking that GC must also do similar searching of pointers, but instead to find what memory blocks were no longer in use. So I reasoned that although searching the "reference" pointers would be relatively inefficient (compared to using "double pointers"), it should be comparable to GC, so I was merely putting this in perspective.
While on this topic (you'll note that I had changed the subject heading, since we really aren't talking about the original GCC-3 issue any more), I had a thought that perhaps rather than setting any "reference" pointers to nil when their corresponding "store" pointer was disposed, perhaps this should really result in a run-time error. That is, you cannot dispose a "store" pointer if it has any "reference" pointers associated with it. This would be better than later in the code, trying to dereference a "reference" pointer, then trying to figure out why/when it became invalid.
Joe.
da Silva, Joe wrote:
Well, I also disagree here. As others have said, this should be up to the programmer to decide, depending on the needs of a particular program (and so it is).
A counter-argument to your argument (which is certainly also valid) would be that Pascal does some things automatically that, e.g., C does not.
Suppose you only know C (horrible thought, I know ;-) and are used to C style strings, i.e. you malloc() them when necessary and free() them when you don't need them anymore, but the language doesn't enforce the latter. When you then hear the statement above about discipline, you might assume that in Pascal you'd also have to allocate every string, but are forced by the language to dispose of it again. As we know, that's not true, because in Pascal you (usually) don't need any heap operations at all to work with strings (cf. string concatenation, string value parameters, functions returning strings).
So, in Pascal there's both -- more things done automatically behind the scenes, but OTOH stricter enforcement of the rules for those things you have to do yourself. In which of these categories you put memory housekeeping, is not obvious I think. (Of course, the standard contains `Dispose', but it doesn't demand that `Dispose' actually does something, or that a program that doesn't call `Dispose' must fail after awhile.)
Frank