From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: Null filename ("") is considered to correspond to an existing, readable, and writable file?
Date: Mon, 2 Jan 2006 19:27:56 -0800 [thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICKEAIDBAA.drew.adams@oracle.com> (raw)
In-Reply-To: <200601030122.k031Mvf24296@raven.dms.auburn.edu>
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?
next prev parent reply other threads:[~2006-01-03 3:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-02 22:57 Null filename ("") is considered to correspond to an existing, readable, and writable file? Drew Adams
2006-01-03 1:22 ` Luc Teirlinck
2006-01-03 3:27 ` Drew Adams [this message]
2006-01-03 4:41 ` Luc Teirlinck
2006-01-03 8:24 ` Drew Adams
2006-01-03 18:13 ` Eli Zaretskii
2006-01-03 4:56 ` Luc Teirlinck
2006-01-03 5:32 ` Eli Zaretskii
2006-01-03 8:25 ` Drew Adams
2006-01-03 15:50 ` Stefan Monnier
2006-01-03 18:51 ` Drew Adams
2006-01-03 19:16 ` Eli Zaretskii
2006-01-03 19:25 ` Drew Adams
2006-01-03 19:40 ` Luc Teirlinck
2006-01-03 20:23 ` Luc Teirlinck
2006-01-03 21:09 ` Drew Adams
2006-01-07 20:04 ` Thien-Thi Nguyen
2006-01-03 18:11 ` Eli Zaretskii
2006-01-03 18:51 ` Drew Adams
2006-01-03 19:13 ` Eli Zaretskii
2006-01-03 19:23 ` Drew Adams
2006-01-03 18:51 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DNEMKBNJBGPAOPIJOOICKEAIDBAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).