From: Philip Kaludercic <philipk@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 65797@debbugs.gnu.org, Joseph Turner <joseph@breatheoutbreathe.in>
Subject: bug#65797: `buffer-match-p` should not use `func-arity`
Date: Tue, 19 Sep 2023 08:34:57 +0000 [thread overview]
Message-ID: <87y1h2blxq.fsf@posteo.net> (raw)
In-Reply-To: <jwva5tje5ak.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 18 Sep 2023 14:05:48 -0400")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> - Deprecate the feature with no replacement (i.e. users will have
>>> to use a (lambda (x y) (foo x)) wrapper to drop the second arg if they
>>> were using the feature). That's my favorite option at this point.
>>
>> I would be disappointed to see this path taken, since part of my hope
>> with buffer-match-p was that it could be used in project.el as well
>> (allowing this to be a thing is one of the reasons I started working on
>> Compat).
>
> I don't understand: you just told me you have no examples of places
> where single-arg functions are concretely useful.
My apologies, to clarify: I don't know of any example where it is
currently used (project.el has a separate implementation), but this
would be one example where a single-argument invocation would be useful.
> So, assuming `buffer-match-p` is used in many other things, like
> `project.el`, do you have examples where the feature of choosing between
> calling sometimes with one arg and sometimes with two would be
> useful/handy?
That is a different matter. Usually if buffer-match-p is not passed an
argument via ARG, then all the function calls would also just have a
single argument. But in other examples, such as display-bufffer-alist
where ARG is non-nil, the user might want to fall back onto ignoring
ARG. OTOH the difference between
(lambda (buf) ...)
and
(lambda (buf _) ...)
is not that great either. So one could invoke the function with two
arguments if ARG is non-nil, and otherwise just with one.
> [ BTW, changing the code to use `&rest args` instead of `&optional arg`
> would help for this, right? ]
How come?
>>> - Replace it with some alternative (e.g. provide two different syntaxes
>>> for functions, one for functions that expect all args and one for
>>> functions that only take a single arg).
>>
>> So `(arg1 ,(lambda (x) ...)) and `(arg2 ,(lambda (x y) ...))?
>
> No, I was more thinking of `(pred1 FOO)` vs `(pred FOO)` or using just
> `FOO` for those functions which take all the arguments and `[FOO]` for
> those functions which only accept a single argument, or any other
> suitable "annotation".
> Or you could use an OClosure which carries some explicit user-provided
> arity info with it.
How would that look like?
>>> - Live with the occasional breakage and bug reports like the current one.
>> The issue here was related to advising a function. And you are saying
>> there is no way around this, not even by annotating the function symbol
>> with the initial arity before it is advised.
>
> No, we can fix this case with some ad-hoc hack.
> But we can't fix every case once and for all, so the hack ends up being
> very costly compared to its benefit.
>
> The general rule is that you should never look at a function to decide
> how to call it (more generally, you should never look at a function
> beyond testing `functionp` or `commandp` (other than for debugging and
> the like), you should only call it).
OK, I see, I was not familiar with this principle.
>
> Stefan
next prev parent reply other threads:[~2023-09-19 8:34 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 7:53 bug#65797: 29.0.92; func-arity should not return (0 . many) with apply-partially Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07 12:35 ` Mattias Engdegård
2023-09-07 15:11 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07 15:17 ` Mattias Engdegård
2023-09-07 13:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07 15:50 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 4:40 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 6:46 ` Eli Zaretskii
2023-09-08 15:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 16:37 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 17:18 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 18:16 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 18:20 ` Eli Zaretskii
2023-09-11 16:57 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-11 18:58 ` Eli Zaretskii
2023-09-12 18:30 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-08 17:01 ` bug#65797: `buffer-match-p` should not use `func-arity` Philip Kaludercic
2023-09-12 18:28 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-13 21:50 ` Philip Kaludercic
2023-09-14 13:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 9:12 ` Philip Kaludercic
2023-09-18 11:55 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-18 17:23 ` Philip Kaludercic
2023-09-18 18:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-19 8:34 ` Philip Kaludercic [this message]
2023-09-19 10:06 ` Dmitry Gutov
2023-09-19 13:56 ` Philip Kaludercic
2023-09-19 16:13 ` Dmitry Gutov
2023-10-08 9:10 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-08 10:25 ` Dmitry Gutov
2023-10-09 21:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-12 4:53 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-12 11:34 ` Dmitry Gutov
2023-10-13 15:57 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-14 6:13 ` Eli Zaretskii
2023-10-14 14:31 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-15 6:13 ` Eli Zaretskii
2023-10-16 16:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-16 20:16 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-10-19 12:18 ` Eli Zaretskii
2023-10-21 2:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15 0:45 ` Dmitry Gutov
2023-09-15 1:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15 16:38 ` Dmitry Gutov
2023-09-15 17:54 ` Joseph Turner via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-15 18:00 ` Dmitry Gutov
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=87y1h2blxq.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=65797@debbugs.gnu.org \
--cc=joseph@breatheoutbreathe.in \
--cc=monnier@iro.umontreal.ca \
/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).