* puzzling byte-compile-file message: `=' called for effect
@ 2005-11-15 14:42 Jim Ottaway
0 siblings, 0 replies; 6+ messages in thread
From: Jim Ottaway @ 2005-11-15 14:42 UTC (permalink / raw)
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?
--
Jim Ottaway
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: puzzling byte-compile-file message: `=' called for effect
[not found] <mailman.15349.1132065762.20277.help-gnu-emacs@gnu.org>
@ 2005-11-15 16:07 ` Yevgeniy Makarov
2005-11-15 16:19 ` Jim Ottaway
2005-11-15 16:39 ` Drew Adams
0 siblings, 2 replies; 6+ messages in thread
From: Yevgeniy Makarov @ 2005-11-15 16:07 UTC (permalink / raw)
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.
Yevgeniy
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: puzzling byte-compile-file message: `=' called for effect
2005-11-15 16:07 ` puzzling byte-compile-file message: `=' called for effect Yevgeniy Makarov
@ 2005-11-15 16:19 ` Jim Ottaway
2005-11-15 16:39 ` Drew Adams
1 sibling, 0 replies; 6+ messages in thread
From: Jim Ottaway @ 2005-11-15 16:19 UTC (permalink / raw)
>>>>> Yevgeniy Makarov <emakarov@cs.indiana.edu> writes:
> 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.
> Yevgeniy
Ahh yes, of course! Thank you, I have the save-excursion in the wrong
place, it should be
(when (save-excursion
(and nl-paras-fixed-p
(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")))
I looked at it for ages without noticing that, thank you again.
Regards,
--
Jim Ottaway
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: puzzling byte-compile-file message: `=' called for effect
2005-11-15 16:07 ` puzzling byte-compile-file message: `=' called for effect Yevgeniy Makarov
2005-11-15 16:19 ` Jim Ottaway
@ 2005-11-15 16:39 ` Drew Adams
2005-11-15 23:22 ` Richard M. Stallman
1 sibling, 1 reply; 6+ messages in thread
From: Drew Adams @ 2005-11-15 16:39 UTC (permalink / raw)
Cc: Emacs-Devel
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: puzzling byte-compile-file message: `=' called for effect
[not found] <mailman.15359.1132072766.20277.help-gnu-emacs@gnu.org>
@ 2005-11-15 17:09 ` Jim Ottaway
0 siblings, 0 replies; 6+ messages in thread
From: Jim Ottaway @ 2005-11-15 17:09 UTC (permalink / raw)
>>>>> Drew Adams <drew.adams@oracle.com> writes:
> 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".
Yes, I agree. I was so puzzled by the elliptical message that I
missed the obvious error in my code.
> The message might better say:
> "Warning: `=' return value ignored. Is the expression useful
> for its side effects?"
Something like that, I agree, even simply "`=' called for side effect
alone".
> Ccing emacs-devel, as I think the message should be clarified
> somehow.
Me too.
Regards,
--
Jim Ottaway
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: puzzling byte-compile-file message: `=' called for effect
2005-11-15 16:39 ` Drew Adams
@ 2005-11-15 23:22 ` Richard M. Stallman
0 siblings, 0 replies; 6+ messages in thread
From: Richard M. Stallman @ 2005-11-15 23:22 UTC (permalink / raw)
Cc: help-gnu-emacs, emacs-devel
The message might better say:
"Warning: `=' return value ignored. Is the expression useful
for its side effects?"
I will clarify the warning text. Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-11-15 23:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.15349.1132065762.20277.help-gnu-emacs@gnu.org>
2005-11-15 16:07 ` puzzling byte-compile-file message: `=' called for effect Yevgeniy Makarov
2005-11-15 16:19 ` Jim Ottaway
2005-11-15 16:39 ` Drew Adams
2005-11-15 23:22 ` Richard M. Stallman
[not found] <mailman.15359.1132072766.20277.help-gnu-emacs@gnu.org>
2005-11-15 17:09 ` Jim Ottaway
2005-11-15 14:42 Jim Ottaway
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).