unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* RE: puzzling byte-compile-file message: `=' called for effect
       [not found] <437A07CF.2030008@cs.indiana.edu>
@ 2005-11-15 16:39 ` Drew Adams
  2005-11-15 23:22   ` Richard M. Stallman
  0 siblings, 1 reply; 3+ 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] 3+ messages in thread

* Re: puzzling byte-compile-file message: `=' called for effect
@ 2005-11-15 17:12 Jim Ottaway
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Ottaway @ 2005-11-15 17:12 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 83 bytes --]


Sorry, I meant to cc this to the emacs-devel list, but forgot to add
the header.


[-- Attachment #2: Type: message/rfc822, Size: 1692 bytes --]

From: Jim Ottaway <j.ottaway@lse.ac.uk>
To: help-gnu-emacs@gnu.org
Cc: 
Subject: Re: puzzling byte-compile-file message: `=' called for effect
Date: Tue, 15 Nov 2005 17:09:35 +0000
Message-ID: <87lkzpltww.fsf@lse.ac.uk>

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

[-- Attachment #3: Type: text/plain, Size: 18 bytes --]



-- 
Jim Ottaway

[-- Attachment #4: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 3+ 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; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2005-11-15 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-15 17:12 puzzling byte-compile-file message: `=' called for effect Jim Ottaway
     [not found] <437A07CF.2030008@cs.indiana.edu>
2005-11-15 16:39 ` Drew Adams
2005-11-15 23:22   ` Richard M. Stallman

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