unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Michael Heerdegen <michael_heerdegen@web.de>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: RE: [External] : Re: master a7c65fc666: Allow nil value for filter-buffer-substring-function
Date: Wed, 21 Sep 2022 15:59:36 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488B1874E2B6E6A6013ABBBF34F9@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87pmfpb4ed.fsf@web.de>

> > The argument that allowing a nil value for such
> > a variable "breaks" the use of `add-function' is
> > no more than a re-assertion that the variable
> > shouldn't have a nil value.
> 
> I don't think this is true.  You are missing an,
> or even the, important point IMO.

I don't think that point was given.  My point was
that an argument that nil should be disallowed for
variables whose names end in `-function' is wrong
(misguided).  It may be reasonable for variable
`filter-buffer-substring-function', and for some
other so-named variables.  But as a general rule
it's misguided, IMO.
 
> > And in particular, the use of function `ignore'
> > is not the same thing as the use of nil to mean
> > "NO function" or "NOT a function" - not at all.
> >
> > No good argument exists for a blanket rule that
                                ^^^^^^^^^^^^^^
> > a var whose value can be a function shouldn't
> > also be allowed other, non-function values - in
> > particular the value nil.  At least we've seen
> > no good argument so far.
> 
> > (eq var 'ignore) or (eq var #'ignore) is more,
> > not less, problematic than (null var).
> >
> > You can certainly use (when var (add-function...))
> > instead of just (add-function...).  Or instead of
> > `apply' or `funcall'.  Not a problem -- or if you
> > think it is then please show the problem.
> 
> I don't think testing the value directly for equivalence
> to some given value is not an important use case:

You don't think it's _not_ an important use case?
Or was that a typo?  I'm guessing the latter,
based on the rest of what you say.

In any case, it may not be important to you, and
it may not be general enough for you or for
everything.  But it can be an important use case
for some code - for some `-function' vars, IMO.

I see no reason that a convention for naming vars
`-function' should be limited to variables whose
value can _only_ be a function.

I'm speaking to the blanket assertion that a
variable whose name ends in `-function', per our
convention, must be expected to only have a
function as its value.  I'm not speaking about
`filter-buffer-substring-function' specifically.

I disagree that that's what this naming is, or
should be, about.  Certainly any so-named var
whose value _must_ always be a function should
have that called out in its doc, and preferably
the code should support/enforce that requirement.
(_Does_ the doc call it out for this var?)

But from there to proclaim that all vars with
names that end in `-function' must only have
function values, I think is inappropriate, and
unnecessary.

It's a naming convention - to help human readers.
It's not a programming declaration - something
that controls code (e.g. byte-compilation), and
it shouldn't be.  (We _could_ have a declaration
for that, if it's helpful/needed.  Or we can
just communicate such things to humans in a doc
string.)

> I think the idea behind this treatment is: we want to allow different
> modes/features, plus the user and/or buffer local configurations etc, to
> push their behavior changes into that variable at the same time (!),
                                   ^^^^^^^^^^^^^

If you mean only `filter-buffer-substring-function'
then I have no objection.  I wasn't speaking about
that variable, or any particular variable.  I was
speaking to a general "rule" about variables with
such a name suffix.

I see now that I could have been clearer about that.
But I did say:

  I don't think that, in general, variables whose
                      ^^^^^^^^^^
  names end in `-function' should be disallowed a
  non-function value - in particular a value of nil.

I was talking about what the naming convention, in
itself, should be expected to mean.  I don't think
it should be expected that all such vars must have
only function values.

> namely by advising it, by wrapping different layers around the value.
> That's only possible if the value is always guaranteed to be a function
> - so this is a requirement per se to allow this kind of approach, not an
> excuse to disallow non-function values.

If you mean that only for this variable, I have no
problem with it.  For instance, I depend on the
same kind of thing you mention, in my code, wrt
`isearch-filter-predicate'.

Of course some vars should be required to have only
function values. And they (too) can benefit from
applying the `-function' naming convention to them.
But they shouldn't "own" (appropriate, pwn) that
convention.

> In this scenario, plain (equal var some-value) tests are quite useless
> because you don't know which modes and features or whatever already
> installed their modifications into the value (changing it).

Of course.

Speaking of which - I think it's a mistake BTW for
function `advice--p' to be "internal".  It's fine
that its implementation might change.  But it's a
fine function for user code to use.  There's no real
alternative, other than directly using the code that
implements it.  (Likewise for `advice--car' etc.)



  parent reply	other threads:[~2022-09-21 15:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <166359943394.15847.12726646376922950024@vcs2.savannah.gnu.org>
     [not found] ` <20220919145714.5036DC00872@vcs2.savannah.gnu.org>
2022-09-19 15:10   ` master a7c65fc666: Allow nil value for filter-buffer-substring-function Robert Pluim
2022-09-19 15:56     ` Stefan Kangas
2022-09-19 20:37     ` Stefan Monnier
2022-09-20  8:08       ` Robert Pluim
2022-09-20 13:23         ` Stefan Monnier
2022-09-19 20:56   ` Stefan Monnier
2022-09-19 21:15     ` Stefan Kangas
2022-09-19 21:58       ` Stefan Monnier
2022-09-20  6:26         ` Stefan Kangas
2022-09-20 15:41     ` [External] : " Drew Adams
2022-09-21  6:58       ` Michael Heerdegen
2022-09-21  7:06         ` Emanuel Berg
2022-09-21 15:59         ` Drew Adams [this message]
2022-09-22  9:59           ` Michael Heerdegen
2022-09-22 15:39             ` Drew Adams
2022-09-23 13:19             ` Stefan Monnier

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=SJ0PR10MB5488B1874E2B6E6A6013ABBBF34F9@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).