Re: close(writefile)
- Posted by useless_ Dec 22, 2012
- 1115 views
I suppose it wouldn't be too much trouble to add another function that can attempt to return a filename for a given file descriptor (when applicable of course), but at this point you might be better off not using file handles at all, instead using read_file() and write_file() or read_lines() and write_lines(), and simply always passing the filename in as a string.
Or a hash of the filename is the integer handle.
I'd prefer the file descriptor be bidrectional on all the data about the file. It's why i usually maintain variables: readfilename, readfile, writefilename, writefile, readfileptr, etc etc.. Sometimes these are nested sequences: readfilenames = {"name1","name2","name3"}, readfiles = {handle1,handle2,handle3} etc.
Constructive critique done, i'd feel a need to bite someone's hand and point out that file handles are recycled and never run out, but task id are not recycled and do run out. Here's some ointment for that bite.
useless