From: "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 58563@debbugs.gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#58563: 29.0.50; Generic functions and advertised-calling-convention
Date: Sun, 16 Oct 2022 13:24:30 +0300 [thread overview]
Message-ID: <878rlgjcbl.fsf@tcd.ie> (raw)
Further to https://bugs.gnu.org/58531#25, generic functions do not
currently support advertised-calling-convention very well (or vice
versa).
For example, starting with:
(cl-defgeneric my-foo (x &optional _y)
"Frobnicate X."
(declare (advertised-calling-convention (x) "29.1"))
x)
Any code that calls my-foo with two arguments correctly gives rise to a
warning during byte-compilation.
C-h f also shows the expected arglist, but not for methods:
my-foo is a Lisp closure.
(my-foo X)
Frobnicate X.
This is a generic function.
Implementations:
(my-foo X &optional _Y)
Undocumented
More importantly, if we now do:
(cl-defmethod my-foo ((x symbol) &optional _y)
"Frobnicate X the symbol."
(declare (advertised-calling-convention (x) "29.1"))
x)
Then my-foo's symbol-function is overwritten and its entry in
advertised-signature-table is no longer found, so byte-compilation no
longer warns about incorrect usage, and C-h f regresses to displaying:
my-foo is a byte-compiled Lisp function.
(my-foo X &optional Y)
Frobnicate X.
This is a generic function.
Implementations:
(my-foo (X symbol) &optional _Y)
Frobnicate X the symbol.
(my-foo X &optional _Y)
Undocumented
Note that, unlike with cl-defgeneric, the declare form in cl-defmethod
does not expand to a call to set-advertised-calling-convention. If
set-advertised-calling-convention is called after the cl-defmethod, then
the advertised-calling-convention is preserved (or rather reinstated),
but only until the next cl-defmethod is defined (which could happen in
third-party code).
I guess either advertised-signature-table should be extended to allow
for the nature of generic functions, or cl-defmethod should be taught to
preserve such function properties (or both).
I wonder if cl-defgeneric should be the single source of this function
property, or whether any cl-defmethod should be able to overload it.
Thoughts?
Thanks,
--
Basil
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars) of 2022-10-16 built on tia
Repository revision: 07222447b6c9e75b713fe3b3954952fbb0e40c71
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Debian GNU/Linux bookworm/sid
next reply other threads:[~2022-10-16 10:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-16 10:24 Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-10-16 10:33 ` bug#58563: 29.0.50; Generic functions and advertised-calling-convention Lars Ingebrigtsen
2022-10-16 14:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 14:27 ` Lars Ingebrigtsen
2022-10-16 14:49 ` Lars Ingebrigtsen
2022-10-16 15:08 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 15:16 ` Lars Ingebrigtsen
2022-10-16 15:35 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 11:10 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 16:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-23 17:15 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-24 19:50 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-26 13:51 ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-26 14:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878rlgjcbl.fsf@tcd.ie \
--to=bug-gnu-emacs@gnu.org \
--cc=58563@debbugs.gnu.org \
--cc=contovob@tcd.ie \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.