[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Null filename ("") is considered to correspond to an existing, reada
From: |
Drew Adams |
Subject: |
RE: Null filename ("") is considered to correspond to an existing, readable, and writable file? |
Date: |
Mon, 2 Jan 2006 19:27:56 -0800 |
The following expressions all return true (on Windows, at
least). I imagine that this is by design (it is an old policy),
but I don't understand the reason for this.
(file-exists-p "")
(file-readable-p "")
(file-writable-p "")
How often would someone want a null filename to be
considered to correspond to an existing, readable,
or writable file?
The empty string is a relative file name. It is the current
directory, given be the buffer-local variable default-directory. Just
do `M-: (find-file ""). There can not be any file with a "null" file
name other than the current directory.
Fine. It should be documented. There are plenty of functions that take an
absolute file-name argument, and others that take a relative file-name
argument. The doc for these particular functions should say that the
argument must be a relative file name.
And they should explicitly point out the case of "". All the more so because
their names can easily mislead you into thinking that an argument of "" will
return a nil result.
`file-writable-p' is not `find-file'.
Also, the doc strings and the manual say nothing about using
a default directory (yes, apparently) or whether the FILENAME
argument must include a directory (it need not, apparently).
It would get rather tedious if every single docstring of any function
handling files had to explain the difference between relative and
absolute file names and if all these docstrings had to document the
variable default-directory.
Tedious, perhaps, but it is, first of all, a reference manual. Many people
will not read it in a linear fashion, front to back. When I want to know
what a function does and how to use it, I look up that function.
Besides, where is the section of the manual that says that, unless stated
otherwise, all file-name arguments to functions are relative, and they are
all relative to the `default-directory'?
The Elisp manual talks about relative and absolute file names and
documents default-directory.
Yes, of course it does. So what? It talks about lists and faces too, but
that doesn't mean that the doc for a function shouldn't specify what its
arguments are.
Beyond the doc, wouldn't you expect functions with these names to return nil
for a "" argument? What's the purpose of not checking this case, correctly
applying the meaning of the function's name and returning nil?
Is it so that you can use (file-exists-p "") to test the existence of
directory `default-directory'? What's the advantage of such a "feature"?
There are other, more readable ways to test that: (file-exists-p
default-directory), for instance.
Sorry, I still don't get it. Why is the design like this?
- Null filename ("") is considered to correspond to an existing, readable, and writable file?, Drew Adams, 2006/01/02
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Luc Teirlinck, 2006/01/02
- RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?,
Drew Adams <=
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Luc Teirlinck, 2006/01/02
- RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Drew Adams, 2006/01/03
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Eli Zaretskii, 2006/01/03
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Luc Teirlinck, 2006/01/03
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Eli Zaretskii, 2006/01/03
- RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Drew Adams, 2006/01/03
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Stefan Monnier, 2006/01/03
- RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Drew Adams, 2006/01/03
- Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Eli Zaretskii, 2006/01/03
- RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?, Drew Adams, 2006/01/03