[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: puzzling byte-compile-file message: `=' called for effect
From: |
Drew Adams |
Subject: |
RE: puzzling byte-compile-file message: `=' called for effect |
Date: |
Tue, 15 Nov 2005 08:39:13 -0800 |
Jim Ottaway wrote:
> When byte-compiling a file, I get this message:
>
> In nl-publish-markup-list:
> nested-lists.el:395:19:Warning: `=' called for effect
>
> What does this mean? I grepped for 'for effect' in Emacs's
> lisp/emacs-lisp subdirectory, and found the relevant parts of
> byte-opt.el, but I am no wiser.
>
> The code with the '=' in it is:
>
> (when (and nl-paras-fixed-p
> (save-excursion
> (goto-char nl-markup-start)
> (goto-char (muse-line-beginning-position))
> (= (forward-line -1) 0)
> (looking-at "^\\S-")))
> (with-current-buffer nl-temp-buffer
> (goto-char (point-min))
> (insert "\n\n")))
>
> Any ideas? Does it mean that the byte-compiler thinks that
> (forward-line -1) will always return 0 at that point? Or does 'for
> effect' mean something else?
Again, I am not an expert, so I don't know if this is useful. But the
fact is that save-excursion executes its arguments in turn and returns
the value of the last one. Therefore, the value of (= (forward-line -1)
0) is not used. This line produces a side effect, however, namely,
(forward-line -1). But the wrapping of = around it does not make sense
because its value is irrelevant for the rest of the program.
The term "for effect" is correct here, but I don't think it is as clear as
it could be. The compiler is suggesting that, if the `=' expression is
useful, it must be useful because of side effects that occur during its
evaluation.
I think the compiler should explicitly say that the resulting _value_ of the
`=' expression is not used. It might also say that the `=' expression may be
useful for its side effects (or side effects of its subexpressions), but the
resulting value has no effect on the overall code. At a minimum, the word
"side" should be added to "effect".
The message might better say:
"Warning: `=' return value ignored. Is the expression useful
for its side effects?"
Ccing emacs-devel, as I think the message should be clarified somehow.
-----
BTW - Another case where you see this "for effect" warning is this:
(and (< emacs-major-version 21) (eval-when-compile (require 'cl)))
When byte-compiled in an Emacs version > 20, the compiler determines that
the (< _ _) expression in this top-level code is FALSE, and lets you know
that the TRUE branch of the `if' is never taken.
In this case, a different message might be better, IMO. The `<' is _not_
called for its side effects but for its value. It's just that the Emacs 22
byte compiler sees that (< 22 21) is always nil. The message should say
something like "`<' expression always returns nil".
HTH.
- RE: puzzling byte-compile-file message: `=' called for effect,
Drew Adams <=