emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bytecomp.el: issue warning when `mapcar' is called for effect


From: Markus Triska
Subject: bytecomp.el: issue warning when `mapcar' is called for effect
Date: Tue, 19 Jun 2007 18:46:39 +0200

This makes the byte-compiler mention `mapc' and `dolist' where one of
them is preferable over `mapcar'.


2007-06-19  Markus Triska  <address@hidden>

        * emacs-lisp/bytecomp.el (byte-compile-normal-call): Issue warning
        when `mapcar' is called for effect.

Index: bytecomp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/emacs-lisp/bytecomp.el,v
retrieving revision 2.202
diff -c -r2.202 bytecomp.el
*** bytecomp.el 14 Jun 2007 21:25:11 -0000      2.202
--- bytecomp.el 19 Jun 2007 16:44:36 -0000
***************
*** 2831,2836 ****
--- 2831,2840 ----
  (defun byte-compile-normal-call (form)
    (if byte-compile-generate-call-tree
        (byte-compile-annotate-call-tree form))
+   (when (and for-effect (eq (car form) 'mapcar))
+     (byte-compile-set-symbol-position 'mapcar)
+     (byte-compile-warn
+      "`mapcar' called for effect; use `mapc' or `dolist' instead"))
    (byte-compile-push-constant (car form))
    (mapc 'byte-compile-form (cdr form))        ; wasteful, but faster.
    (byte-compile-out 'byte-call (length (cdr form))))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]