>> (PS: An alternative scheme would be to introduce a reference counter
f.refcnt,
which is increased in Files.Old and decreased in Files.Close,
which would in
addition remove a file descriptor from the list if the
counter reaches 0. But that
would make things more complicated).
I'm afraid the reference counter will not solve the issue, because, firstly, one is
not asked to call Files.Close, one can just leave the file as is, and in this case the
file descriptor will still need to be collected if there are no references to it. And,
secondly, Files.Close does not actually "close" the file, but it just flushes the
buffers, and after Files.Close the file can be still read from and written to.
More calls to Files.Close can be done later. "Close" means "close the buffers".