* bug#13676: 24.2.93; Compiler warnings with (defalias #'symbol ...)
@ 2013-02-10 17:14 Michael Heerdegen
2013-02-11 4:01 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Michael Heerdegen @ 2013-02-10 17:14 UTC (permalink / raw)
To: 13676
Hi,
after reading (long ago) in (elisp) Anonymous Functions:
,----------------------------------------------------------------------
| -- Special Form: function function-object
|
| [...] But unlike `quote', it also serves as a note to the Emacs
|evaluator and byte-compiler that FUNCTION-OBJECT is intended to be used
|as a function. [...]
`----------------------------------------------------------------------
I often used something like this:
--8<---------------cut here---------------start------------->8---
;; my package --- doing cool stuff
(defalias #'my-package-end-of-line
(if (fboundp #'end-of-visual-line)
#'end-of-visual-line
#'end-of-line))
(defun my-package-do-cool-stuff ()
"Doc..."
(ding)
(goto-char (point-min))
(my-package-end-of-line))
--8<---------------cut here---------------end--------------->8---
If I compile this, I get a warning:
,----------------------------------------------------------------------
| Compiling file /home/micha/today/my-package.el at Sun Feb 10 17:54:08 2013
|
| In end of data:
| my-package.el:13:1:Warning: the function `my-package-end-of-line' is not known
| to be defined.
`----------------------------------------------------------------------
If the first arg of `defalias' is quoted with just quote (instead of
`#''), however, you don't get a warning.
Dunno if it's no good style to use `#'' at that place - OTOH, it works,
and the warning is not useful.
A fix would presumably need to change the first condition of the `pcase' in
`byte-compile-file-form-defalias', probably to something like
`(,_ ,(or `',name `(function ,name)) ,arg . ,rest)
Thanks,
Michael.
In GNU Emacs 24.2.93.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10)
of 2013-02-09 on drachen
Bzr revision: cyd@gnu.org-20130209044342-t2b063zu2fqy8nud
Windowing system distributor `The X.Org Foundation', version 11.0.10707000
System Description: Debian GNU/Linux 7.0 (wheezy)
Configured using:
`configure '--prefix=/usr/local/built/''
Important settings:
value of $LC_ALL: de_DE.utf8
value of $LC_TIME: C
value of $LANG: de_DE.utf8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#13676: 24.2.93; Compiler warnings with (defalias #'symbol ...)
2013-02-10 17:14 bug#13676: 24.2.93; Compiler warnings with (defalias #'symbol ...) Michael Heerdegen
@ 2013-02-11 4:01 ` Stefan Monnier
2013-02-11 15:04 ` Michael Heerdegen
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-02-11 4:01 UTC (permalink / raw)
To: michael_heerdegen; +Cc: 13676
> | [...] But unlike `quote', it also serves as a note to the Emacs
> |evaluator and byte-compiler that FUNCTION-OBJECT is intended to be used
> |as a function. [...]
Right, this means that #'foo is a reference to the function stored in `foo'.
> (defalias #'my-package-end-of-line
So, this is weird, because you're not referring to the function stored
in `my-package-end-of-line' here, instead you really want to set the
`symbol-function' slot of the symbol, so the argument you want to pass
to `defalias' is not a function but a symbol.
Both work in practice, but the intention expressed by the use of #' is
incorrect here.
> (if (fboundp #'end-of-visual-line)
Similarly, here it should be (fboundp 'end-of-visual-line) since
fboundp's argument should be a symbol, not a function.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#13676: 24.2.93; Compiler warnings with (defalias #'symbol ...)
2013-02-11 4:01 ` Stefan Monnier
@ 2013-02-11 15:04 ` Michael Heerdegen
0 siblings, 0 replies; 3+ messages in thread
From: Michael Heerdegen @ 2013-02-11 15:04 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 13676
Hello Stefan,
thanks for the explanation. I'll close it.
Michael.
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> > | [...] But unlike `quote', it also serves as a note to the Emacs
> > |evaluator and byte-compiler that FUNCTION-OBJECT is intended to be used
> > |as a function. [...]
>
> Right, this means that #'foo is a reference to the function stored in
> foo'.
>
> > (defalias #'my-package-end-of-line
>
> So, this is weird, because you're not referring to the function stored
> in `my-package-end-of-line' here, instead you really want to set the
> `symbol-function' slot of the symbol, so the argument you want to pass
> to `defalias' is not a function but a symbol.
>
> Both work in practice, but the intention expressed by the use of #' is
> incorrect here.
>
> > (if (fboundp #'end-of-visual-line)
>
> Similarly, here it should be (fboundp 'end-of-visual-line) since
> fboundp's argument should be a symbol, not a function.
>
>
> Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-11 15:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-10 17:14 bug#13676: 24.2.93; Compiler warnings with (defalias #'symbol ...) Michael Heerdegen
2013-02-11 4:01 ` Stefan Monnier
2013-02-11 15:04 ` Michael Heerdegen
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.