Hey, In non-standard Pascal mode, does it matter if I explicitly close the file or not? E.g., "close(file);", is that done automatically or is it implementation defined? (I'm 99% sure DOS always closes files upon exit.) I'm just wondering if that's a fair assumption for Linux, etc. (though I kinda doubt it).
Why rely on implementation? One good coding practice is to close what you've opened. AFAIK in most Pascal implementation, even if the OS will close the file upon program exit, the buffer that contains something you write will not be flushed. So you will lose everything you've written.
Rugxulo wrote:
Hey, In non-standard Pascal mode, does it matter if I explicitly close the file or not? E.g., "close(file);", is that done automatically or is it implementation defined? (I'm 99% sure DOS always closes files upon exit.) I'm just wondering if that's a fair assumption for Linux, etc. (though I kinda doubt it).
On Mon, 14 Jun 2010, Rugxulo wrote:
Hey, In non-standard Pascal mode, does it matter if I explicitly close the file or not? E.g., "close(file);", is that done automatically or is it implementation defined? (I'm 99% sure DOS always closes files upon exit.) I'm just wondering if that's a fair assumption for Linux, etc. (though I kinda doubt it).
I believe most, if not all, modern operating systems automatically close all open files when a process terminates, but I've never relied on that. It's nearly always better to close files explicitly. The only exception I can think of is if you're working in a language like AWK or SAS which opens and closes files automatically (Pascal doesn't fall into that category).
--------------------------| John L. Ries | Salford Systems | Phone: (619)543-8880 x107 | or (435)867-8885 | --------------------------|