GNU bug report logs - #58563
29.0.50; Generic functions and advertised-calling-convention

Previous Next

Package: emacs;

Reported by: "Basil L. Contovounesios" <contovob <at> tcd.ie>

Date: Sun, 16 Oct 2022 10:25:01 UTC

Severity: normal

Tags: patch

Found in versions 29.0.50, 25.3.1

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Subject: bug#58563: closed (Re: bug#58563: 29.0.50; Generic functions and
 advertised-calling-convention)
Date: Wed, 26 Oct 2022 14:46:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#58563: 29.0.50; Generic functions and advertised-calling-convention

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 58563 <at> debbugs.gnu.org.

-- 
58563: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=58563
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Cc: 58563-done <at> debbugs.gnu.org
Subject: Re: bug#58563: 29.0.50; Generic functions and
 advertised-calling-convention
Date: Wed, 26 Oct 2022 10:45:13 -0400
Basil L. Contovounesios [2022-10-26 16:51:22] wrote:
> Agreed.  So is there something left to be done here, or can this bug be
> closed?

Let's see...


        Stefan


[Message part 3 (message/rfc822, inline)]
From: "Basil L. Contovounesios" <contovob <at> tcd.ie>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Generic functions and advertised-calling-convention
Date: Sun, 16 Oct 2022 13:24:30 +0300
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



This bug report was last modified 2 years and 300 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.