[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
I don't remember this being discussed on this bboard, so here it goes...
I think the definition of (file-length) on page 425 of the aluminum edition
leaves something to be desired. In particular, I object to the first
sentence: "<file-stream> must be a stream that is open to a file."
This requirement was probably dictated by the desire to return the length
in exactly the same units that were used to create the file. Reasonable as
this seems, it presents a lot of problems.
For one thing, it always forces you to write something like
(when probe-file FILE-NAME
(little-dummy-stream FILE-NAME :direction :input)
... (file-length little-dummy-stream) ...
even when you don't want to read the file at all, but just see how big it
is. This is not exactly clear, I think.
Things are a lot worse, though, when you move into a networking environment.
One such environment, which I will use as an example, is Spice. Imagine
now you want to check the length of a remote file in Spice; imagine, say,
that you are worried about whether you'd be able to retrieve a huge
database file and fit in on your local disk. The Spice networking stuff is
perfectly happy with a "length of remote file" request, and will tell you
you do not have room. Imagine, though, that you wanted to do the same
thing from within Common Lisp. Well, you have to play the little
(with-open-file ...) game. BUT, in the Spice world (as in many, many other
worlds) this means you indeed want to read the file, all of it! As a
result, the file is shipped over to your machine, taking 5 minutes if you
are lucky. And if you are unlucky, the file will overflow your paging space
(not your file-system space, obviously, because you are NOT retrieving the
file to the file system, by golly, just checking its size!).
All of this is complete nonsense, obviously, when you could have gotten the
same reply in a millisecond if you just didn't have to open the file.
I suppose one could expand on the idea of (open :direction :probe), but
this still seems artificial. Why not just say that file-length takes "a
filename or a stream that is open to a file", like file-write-date, and
maybe let you specify what units you want file-length to return?
- From: Kent M Pitman <KMP@SCRC-STONY-BROOK.ARPA>