[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Can the byte-compiler check whether functions passed by name are def
From: |
Klaus-Dieter Bauer |
Subject: |
Re: Can the byte-compiler check whether functions passed by name are defined? |
Date: |
Thu, 8 Aug 2013 10:44:19 +0200 |
2013/8/8 Stefan Monnier <address@hidden>:
>> (defun foo (&rest args) t)
>> (defun foo2 () (mapcar #'foo '(1 2 3)))
> [...]
>> foo.el:6:1:Warning: the function `foo' is not known to be defined.
>
>> (defun foo () #'assoc-ignore-case)
> [...]
>> foo.el:1:8:Warning: `function' is an obsolete variable.
>
> The patch below should fix them, indeed, thanks.
>
>
> Stefan
>
>
> === modified file 'lisp/emacs-lisp/bytecomp.el'
> --- lisp/emacs-lisp/bytecomp.el 2013-08-07 17:33:30 +0000
> +++ lisp/emacs-lisp/bytecomp.el 2013-08-08 01:23:52 +0000
> @@ -3574,12 +3574,12 @@
> (when (and (symbolp f)
> (byte-compile-warning-enabled-p 'callargs))
> (when (get f 'byte-obsolete-info)
> - (byte-compile-warn-obsolete (car form)))
> + (byte-compile-warn-obsolete f))
>
> ;; Check to see if the function will be available at runtime
> ;; and/or remember its arity if it's unknown.
> (or (and (or (fboundp f) ; Might be a subr or autoload.
> - (byte-compile-fdefinition (car form) nil))
> + (byte-compile-fdefinition f nil))
> (not (memq f byte-compile-noruntime-functions)))
> (eq f byte-compile-current-form) ; ## This doesn't work
> ; with recursion.
>
Applying either of your patches fails for me; Is there some
possibility we can check, that we are actually starting from the same
version of bytecomp.el? I have to admit, I don't have particularily
much experience with patchibg files...
What I intended to check: Does your code allow defining a function
after its first use as #'FUNCTION, as is allowed with normal function
calls (FUNCTION ...)?
>> (funcall (if t #'foo) "Hello World")
>
>(if t #'foo) gets optimized into #'foo.
Okay, I missed that one. If I write
(funcall (if (some-condition) #'foo) nil)
it warns only about some-condition. I have now moved the call to
`byte-compile--higher-order--check-arguments' to `byte-compile-form'
in my code.
The code
(funcall (if (some-condition) #'foo) nil)
(mapc 'foo nil)
(ignore '(#'bar))
No produces the warnings
-------------------------------------------------------
In toplevel form:
id1379159421d7d15c.el:7:1:Warning: mapc: Function argument should be passed as
#'foo, not (quote foo)
In end of data:
id1379159421d7d15c.el:11:1:Warning: The symbol `foo' was used as function name
but the function is not known to be defined.
id1379159421d7d15c.el:11:1:Warning: the function `some-condition' is not known
to be defined.
Wrote c:/tmp/id1379159421d7d15c.elc
Done.
-------------------------------------------------------
- Klaus
bytecomp.el.klaus3.patch
Description: Binary data
- Re: Can the byte-compiler check whether functions passed by name are defined?, (continued)
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/05
- Re: Can the byte-compiler check whether functions passed by name are defined?, Klaus-Dieter Bauer, 2013/08/05
- Re: Can the byte-compiler check whether functions passed by name are defined?, Klaus-Dieter Bauer, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Klaus-Dieter Bauer, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Glenn Morris, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Glenn Morris, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?,
Klaus-Dieter Bauer <=
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/08
- Re: Can the byte-compiler check whether functions passed by name are defined?, Klaus-Dieter Bauer, 2013/08/07
- Re: Can the byte-compiler check whether functions passed by name are defined?, Stefan Monnier, 2013/08/07