emacs-devel
[Top][All Lists]
Advanced

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

Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'


From: Reiner Steib
Subject: Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
Date: Mon, 22 Oct 2007 20:49:27 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

On Mon, Oct 22 2007, Katsumi Yamaoka wrote:

>>>>>> Dan Nicolaescu wrote:
>> The subject is about a new warning produced by the byte
>> compiler. There's a lot of those for gnus.
>> Assuming that all emacs versions that gnus wants to support have
>> either mapc or dolist, can somebody please take care of these
>> warnings?
>
>> Thanks
>
> With No Gnus v0.7 I did `cd lisp; make warn' and tried replacing
> of `mapcar' with `mapc', `dolist', or `while' loops for a while,
> and realized it's not easy and not safe.  Ones who do it will
> need to study what things using `mapcar' do in all cases.  For
> instance, `mapcar' used in `gnus-group-highlight-line' cannot be
> replaced with `mapc' even if the compiler warns it.  

Could the byte-compiler be improved not to warn about such cases?
Here's the relevant code:

(defun gnus-group-highlight-line ()
  "Highlight the current line according to `gnus-group-highlight'."
  (let* ([...]
         (mailp (apply 'append
                       (mapcar
                        (lambda (x)
                          (memq x (assoc (symbol-name
                                          (car (or method gnus-select-method)))
                                         gnus-valid-select-methods)))
                        '(mail post-mail))))
         (level (or (gnus-info-level info) gnus-level-killed))

> In addition, we'd better use `while' loops (or `dolist') rather than
> `mapc' because it is faster, though it needs more work.  I think
> it's worth working anyway but it will take time.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




reply via email to

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