all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bytecomp.el: issue warning when `mapcar' is called for effect
@ 2007-06-19 16:46 Markus Triska
  2007-06-19 16:59 ` Drew Adams
  2007-06-20 13:28 ` Richard Stallman
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Triska @ 2007-06-19 16:46 UTC (permalink / raw)
  To: emacs-devel


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


2007-06-19  Markus Triska  <markus.triska@gmx.at>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-06-20 13:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 16:46 bytecomp.el: issue warning when `mapcar' is called for effect Markus Triska
2007-06-19 16:59 ` Drew Adams
2007-06-20 13:28 ` Richard Stallman

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.