unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20509: compiler warns about cl-defmethod defined after use
@ 2015-05-05 18:16 Glenn Morris
  2015-05-05 20:00 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2015-05-05 18:16 UTC (permalink / raw
  To: 20509

Package: emacs
Version: 25.0.50

Compiling foo.el with contents:
    
    (require 'cl-lib)
    
    (defun foo-1 ()
      (foo-2))
    
    (cl-defmethod foo-2 ()
      t)

results in:

   In end of data:
   foo.el:8:1:Warning: the function `foo-2' is not known to be defined.


There is no such warning when using defun instead of cl-defmethod,
or if foo-2 is moved before foo-1.


I see that cl-defmethod macroexpands to something using declare-function.
Adding

  (setq byte-compile-unresolved-functions
       (delq (assq fn byte-compile-unresolved-functions)
             byte-compile-unresolved-functions))

to byte-compile-macroexpand-declare-function solves the issue,
but I'm not sure it is right, since it might stop
byte-compile-arglist-warn doing its job (?).

On the other hand, it would be consistent with what
byte-compile-file-form-autoload does (see comment in the code).

On the other other hand, declare-function's currently have to come
before any use of the function thay are declaring, which is somewhat
intentional.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#20509: compiler warns about cl-defmethod defined after use
  2015-05-05 18:16 bug#20509: compiler warns about cl-defmethod defined after use Glenn Morris
@ 2015-05-05 20:00 ` Stefan Monnier
  2015-05-06  3:17   ` Glenn Morris
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2015-05-05 20:00 UTC (permalink / raw
  To: Glenn Morris; +Cc: 20509

>     (require 'cl-lib)
>     (defun foo-1 ()
>       (foo-2))
>     (cl-defmethod foo-2 ()
>       t)

While using cl-defmethod without a previous cl-defgeneric is supported,
it's not recommended.


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#20509: compiler warns about cl-defmethod defined after use
  2015-05-05 20:00 ` Stefan Monnier
@ 2015-05-06  3:17   ` Glenn Morris
  2015-05-06  4:28     ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2015-05-06  3:17 UTC (permalink / raw
  To: Stefan Monnier; +Cc: 20509

Stefan Monnier wrote:

> While using cl-defmethod without a previous cl-defgeneric is supported,
> it's not recommended.

It's used without one in several places in Emacs:

emacs-lisp/eieio-custom.el:472:1:Warning: the following functions are not
    known to be defined: eieio-customize-object,
    eieio-custom-object-apply-reset, eieio-custom-widget-insert

emacs-lisp/eieio-speedbar.el:426:1:Warning: the following functions are not
    known to be defined: eieio-speedbar-make-tag-line,
    eieio-speedbar-object-children, eieio-speedbar-expand

cedet/ede/base.el:662:1:Warning: the following functions are not known to be
    defined: ede-buffer-header-file, ede-target-sourcecode,
    ede-buffer-documentation-files, ede-documentation,
    ede-html-documentation

cedet/ede/config.el:417:1:Warning: the following functions are not known to be
    defined: ede-config-get-configuration,
    ede-config-setup-configuration,
    ede-commit

cedet/ede/custom.el:216:1:Warning: the following functions are not known to be
    defined: ede-customize, ede-commit-project


etc etc.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#20509: compiler warns about cl-defmethod defined after use
  2015-05-06  3:17   ` Glenn Morris
@ 2015-05-06  4:28     ` Stefan Monnier
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2015-05-06  4:28 UTC (permalink / raw
  To: Glenn Morris; +Cc: 20509

>> While using cl-defmethod without a previous cl-defgeneric is supported,
>> it's not recommended.
> It's used without one in several places in Emacs:

That's because EIEIO's older `defmethod' always counted as
a "full" definition.  We can fix those warnings in one of the following ways:
- Add a corresponding cl-defgeneric.
- Add a corresponding `require' which loads the package where the
  corresponding `cl-defgeneric' is found.
- Reorder the code so that the cl-defmethod appears before the call(s).
- Change cl-generic.el to use the same kind of bytecompiler hack that
  eieio used to use instead if using `declare-function'.


        Stefan





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-05-06  4:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-05 18:16 bug#20509: compiler warns about cl-defmethod defined after use Glenn Morris
2015-05-05 20:00 ` Stefan Monnier
2015-05-06  3:17   ` Glenn Morris
2015-05-06  4:28     ` Stefan Monnier

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).