unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Emacs-devel@gnu.org
Subject: Re: Improve reporting of I/O, access errors for Emacs
Date: Fri, 13 Sep 2019 10:37:52 +0300	[thread overview]
Message-ID: <8336h01wa7.fsf@gnu.org> (raw)
In-Reply-To: <ba6acf65-635b-b9a4-8769-940c01e3ed04@cs.ucla.edu> (message from Paul Eggert on Thu, 12 Sep 2019 13:32:16 -0700)

> Cc: Emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Thu, 12 Sep 2019 13:32:16 -0700
> 
> On 9/12/19 12:34 PM, Eli Zaretskii wrote:
> > We should just set
> > errno and return an error indication, and then let the caller deal
> > with that.
> 
> I don't see how that could work. Callers are typically written in Lisp, 
> and so can't see errno.

There's some kind of misunderstanding here: the 3 functions I
mentioned are not Lisp-callable, they are called, directly or
indirectly, by Lisp primitives written in C.  My point was that in the
code of the primitive itself, we have all the information to decide
whether or not to signal an error; but on lower levels, we don't have
enough context to make such decisions, so we should only return an
error indication from those lower levels.

> For example, suppose Lisp code calls (file-symlink-p "/a/b/c") and Emacs 
> cannot tell whether /a/b/c is a symbolic link because of an I/O error, 
> or because of a timeout in network access, or because /a is a symlink 
> into an unreadable directory, or whatever. If file-symlink-p merely 
> returns nil, there's no way for the Lisp code to know that there was an 
> exceptional situation and the Lisp code will continue based on the 
> incorrect assumption that /a/b/c was not a symlink.

I agree that file-symlink-p, being a primitive, can decide to signal
an error in case of I/O errors.  But I wasn't talking about the level
of primitives, I was talking about lower levels.  E.g.,
file_directory_p has no way of making intelligent decisions regarding
whether its caller should or shouldn't signal an error in some case,
because file_directory_p can be called in a variety of use cases and
contexts, about whose details it knows nothing at all.

> > That's too small a sample, so it doesn't prove much in my book, sorry.
> 
> I've looked at and experimented with a reasonable amount of Elisp code, 
> and haven't run into problems with the proposed patch. What's your 
> contrary intuition based on? Can you give a realistic example of the 
> problems you see from the patch?

See above: it sounds wrong to delegate to very low levels an authority
of failing the entire higher-level application, since those low levels
don't have enough context information to make such decisions.



  reply	other threads:[~2019-09-13  7:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-12  8:22 Improve reporting of I/O, access errors for Emacs Paul Eggert
2019-09-12 18:04 ` Eli Zaretskii
2019-09-12 18:27   ` Paul Eggert
2019-09-12 19:34     ` Eli Zaretskii
2019-09-12 20:32       ` Paul Eggert
2019-09-13  7:37         ` Eli Zaretskii [this message]
2019-09-18  2:25           ` Paul Eggert
2019-09-18  9:50             ` Richard Copley
2019-09-16 11:07 ` Richard Copley
2019-09-16 14:53   ` Eli Zaretskii
2019-09-16 18:11     ` Richard Copley

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=8336h01wa7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=Emacs-devel@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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).