Michael Latta wrote:
On Jun 27, 2004, at 8:57 AM, Ian Woollard wrote:
And the file may be automagically closed as f goes out of scope.
But this is unreliable in Java/Self/Smalltalk- you don't know when the GC will get around to release it. I consider this to be a bug in these languages.
This is inly an issue if you rely on the garbage collector to close files (which most experienced programmers do not).
No, no. You should not assume that because that feature involves running the destructor in C++ - that the garbage collector should be involved.
My point is that a relatively trivial change to the language gets this capability without involving the GC at all.
In any event this is not a language issue, but a library issue.
No. This problem cannot be solved in libraries- only by having a diligent programmer call the close function in all cases at the right time. I prefer for the language specification to permit the libraries to guarantee that this be done automatically.
Is this extra complexity in the language? Yes.