[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FILE-LENGTH
Date: Thu 07 Mar 85 17:26:25-EST
From: dzg@CMU-CS-SPICE
... For one thing, it always forces you to write something like
(when probe-file FILE-NAME
(with-open-file
(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...
I agree this is lousy. I hate idiomatic usages like this. They're a pain
to read even when you recognize them and some people seem to have a talent
for picking ways to code the same idea in ways that are much less
intelligible than you could ever guessed could be devised...
Why not just let FILE-LENGTH take an optional ELEMENT-TYPE argument
to be used if the operation has to be simulated. If the file is already
open and is not of the given ELEMENT-TYPE, then signal an error if it's
not possible to convert from the given element type to the type the file
is open in. If the file is not open (ie, arg was a path instead of a stream),
then if the operating system primitively supports a file-length operation
on closed files and the ELEMENT-TYPE given is compatible with the type of
the file, then allow the system to optimize out the idiomatic OPEN given
above, and otherwise just simulate it in whatever way is convenient. Seems
to me like that would be portable.
-kmp