[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change in files.el

From: Eli Zaretskii
Subject: Re: Change in files.el
Date: Sat, 28 Jan 2017 18:08:20 +0200

> From: Stefan Monnier <address@hidden>
> Date: Sat, 28 Jan 2017 10:40:41 -0500
> >> - So that you don't have to wrap each and every use inside an `if'.
> >> - Or so you don't have to fix the docstring to say what happens when the
> >> value is nil.
> >> - Or so you can use `add-function' on it.
> >> - More generally, so that you can slightly change its behavior without
> >> having to re-implement the default behavior by hand.
> >> - Also, so as to make sure that it is *possible* to reimplement the
> >> default behavior by hand (i.e. to make sure the predicate has access to all
> >> the info it needs to reproduce the default behavior).
> > These sound minor to me (and the last two are also possible without
> > the requirement, AFAIU).
> Hmm... how do you get the last two without that requirement?

Are we still talking about a predicate, i.e. a function that returns
either t or nil?  If so, I think the last two are so trivial that I
don't know where to begin answering your question.

> > By contrast, insisting on a function value instead of the default nil
> > forces me to go through at least one more level of indirection when
> > I need to understand what happens in a function that references such
> > variables, which sounds like a more serious trouble from my POV.
> I don't follow, sorry.  I don't understand what you mean by "go through
> at least one more level of indirection" here.  Could you explain with
> an example.

Let's say I'm looking at this code:

  (defcustom save-some-buffers-default-predicate nil

  (unless pred
    (setq pred save-some-buffers-default-predicate))
  (if pred DO-SOMETHING)

Here I know immediately what happens when PRED is nil and
save-some-buffers-default-predicate is at its default value.  By
contrast, this:

  (defcustom save-some-buffers-default-predicate #'some-func

  (if save-some-buffers-default-predicate DO-SOMETHING)

requires me to go and look at some-func, which is "one more level of

reply via email to

[Prev in Thread] Current Thread [Next in Thread]