Gnus development mailing list
 help / color / mirror / Atom feed
* Warning: `mapcar' called for effect; use `mapc' or `dolist'
@ 2007-10-20  6:43 Dan Nicolaescu
  2007-10-22 12:13 ` Katsumi Yamaoka
  0 siblings, 1 reply; 28+ messages in thread
From: Dan Nicolaescu @ 2007-10-20  6:43 UTC (permalink / raw)
  To: ding


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

        --dan



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-20  6:43 Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
@ 2007-10-22 12:13 ` Katsumi Yamaoka
  2007-10-22 18:49   ` Reiner Steib
                     ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Katsumi Yamaoka @ 2007-10-22 12:13 UTC (permalink / raw)
  To: ding

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

Regards,



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 12:13 ` Katsumi Yamaoka
@ 2007-10-22 18:49   ` Reiner Steib
  2007-10-22 20:07     ` Dan Nicolaescu
  2007-10-24 19:28   ` Reiner Steib
  2007-10-28 16:58   ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
  2 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-22 18:49 UTC (permalink / raw)
  To: ding; +Cc: Dan Nicolaescu, emacs-devel

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/

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 18:49   ` Reiner Steib
@ 2007-10-22 20:07     ` Dan Nicolaescu
  2007-10-22 20:55       ` Reiner Steib
  0 siblings, 1 reply; 28+ messages in thread
From: Dan Nicolaescu @ 2007-10-22 20:07 UTC (permalink / raw)
  To: Reiner Steib; +Cc: ding, emacs-devel

Reiner Steib <reinersteib+gmane@imap.cc> writes:

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

It seems that `mailp' is not used in that function. Adding a use for
it makes the warning go away...

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:07     ` Dan Nicolaescu
@ 2007-10-22 20:55       ` Reiner Steib
  2007-10-22 21:04         ` Dan Nicolaescu
                           ` (4 more replies)
  0 siblings, 5 replies; 28+ messages in thread
From: Reiner Steib @ 2007-10-22 20:55 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: ding, emacs-devel

On Mon, Oct 22 2007, Dan Nicolaescu wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
>   > On Mon, Oct 22 2007, Katsumi Yamaoka wrote:
>   > > 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'."
[...]
> It seems that `mailp' is not used in that function. 

`mailp' is used implicitly through the variable `gnus-group-highlight'
which is let-bound to `list'.  `list' is used in the body of the
let-form.

> Adding a use for it makes the warning go away...

Hm, I can't reproduce the warning using `emacs-lisp-byte-compile' with
GNU Emacs 23.0.50.6 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-10-20.
Too old?

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



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:55       ` Reiner Steib
@ 2007-10-22 21:04         ` Dan Nicolaescu
  2007-10-22 21:39           ` Glenn Morris
  2007-10-23  1:01         ` Miles Bader
                           ` (3 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Dan Nicolaescu @ 2007-10-22 21:04 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Reiner Steib <reinersteib+gmane@imap.cc> writes:

  > On Mon, Oct 22 2007, Dan Nicolaescu wrote:
  > 
  > > Reiner Steib <reinersteib+gmane@imap.cc> writes:
  > >   > On Mon, Oct 22 2007, Katsumi Yamaoka wrote:
  > >   > > 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'."
  > [...]
  > > It seems that `mailp' is not used in that function. 
  > 
  > `mailp' is used implicitly through the variable `gnus-group-highlight'
  > which is let-bound to `list'.  `list' is used in the body of the
  > let-form.
  > 
  > > Adding a use for it makes the warning go away...
  > 
  > Hm, I can't reproduce the warning using `emacs-lisp-byte-compile' with
  > GNU Emacs 23.0.50.6 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-10-20.
  > Too old?

I can't either. I thought that adding a use for mailp fixed the
warning for me, I didn't try it before that.

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 21:04         ` Dan Nicolaescu
@ 2007-10-22 21:39           ` Glenn Morris
  0 siblings, 0 replies; 28+ messages in thread
From: Glenn Morris @ 2007-10-22 21:39 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: ding, emacs-devel

Dan Nicolaescu wrote:

> Reiner Steib <reinersteib+gmane@imap.cc> writes:
[...]
>   > Hm, I can't reproduce the warning using `emacs-lisp-byte-compile' with
>   > GNU Emacs 23.0.50.6 (i686-pc-linux-gnu, GTK+ Version 2.10.6) of 2007-10-20.
>   > Too old?
>
> I can't either.

I see the warning only when bootstrapping (in an up-to-date CVS). If I
repeat the same commands as used during bootstrapping, except using
the dumped "emacs" instead of "bootstrap-emacs", I still don't see the
warning:

  cd lisp
  rm gnus/gnus-group.elc
  EMACSLOADPATH=$PWD ../src/emacs \
   -batch --no-site-file --multibyte -f batch-byte-compile-if-not-done \
   gnus/gnus-group.el

Something to do with custom perhaps?

Anyway, regardless of this, from having replaced some mapcars in the
non-gnus parts of the trunk, I can say that the replacement is not
just something that can be done automatically, someone should look at
the actual code in each case.

It shouldn't take very long, and ought to eliminate ~ 100/370 of the
current bootstrap warnings. (There's not much point if the gnus in the
Emacs CVS will soon be replaced with gnus trunk though.)

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:55       ` Reiner Steib
  2007-10-22 21:04         ` Dan Nicolaescu
@ 2007-10-23  1:01         ` Miles Bader
  2007-10-23 10:39           ` Richard Stallman
  2007-10-23 10:39         ` Richard Stallman
                           ` (2 subsequent siblings)
  4 siblings, 1 reply; 28+ messages in thread
From: Miles Bader @ 2007-10-23  1:01 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: ding, emacs-devel

Reiner Steib <reinersteib+gmane@imap.cc> writes:
>> It seems that `mailp' is not used in that function. 
>
> `mailp' is used implicitly through the variable `gnus-group-highlight'
> which is let-bound to `list'.  `list' is used in the body of the
> let-form.

Ugh.... that's awful.

You should `defvar' mailp then.

-miles
-- 
Everywhere is walking distance if you have the time.  -- Steven Wright

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:55       ` Reiner Steib
  2007-10-22 21:04         ` Dan Nicolaescu
  2007-10-23  1:01         ` Miles Bader
@ 2007-10-23 10:39         ` Richard Stallman
  2007-10-27 10:46           ` Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
                             ` (2 more replies)
  2007-10-23 10:39         ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Richard Stallman
  2007-10-31  7:46         ` Richard Stallman
  4 siblings, 3 replies; 28+ messages in thread
From: Richard Stallman @ 2007-10-23 10:39 UTC (permalink / raw)
  To: Reiner Steib; +Cc: dann, ding

    >   > (defun gnus-group-highlight-line ()
    >   >   "Highlight the current line according to `gnus-group-highlight'."
    [...]
    > It seems that `mailp' is not used in that function. 

    `mailp' is used implicitly through the variable `gnus-group-highlight'
    which is let-bound to `list'.  `list' is used in the body of the
    let-form.

That code is a terrible crock.  Would you please rewrite it to make it
clearer?

I added a `risky-local-variable' property to `gnus-group-highlight'.
Are there any other such variables in Gnus which contain forms to
evaluate?



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:55       ` Reiner Steib
                           ` (2 preceding siblings ...)
  2007-10-23 10:39         ` Richard Stallman
@ 2007-10-23 10:39         ` Richard Stallman
  2007-10-31  7:46         ` Richard Stallman
  4 siblings, 0 replies; 28+ messages in thread
From: Richard Stallman @ 2007-10-23 10:39 UTC (permalink / raw)
  To: Reiner Steib; +Cc: dann, ding, emacs-devel

    >   > (defun gnus-group-highlight-line ()
    >   >   "Highlight the current line according to `gnus-group-highlight'."
    [...]
    > It seems that `mailp' is not used in that function. 

    `mailp' is used implicitly through the variable `gnus-group-highlight'
    which is let-bound to `list'.  `list' is used in the body of the
    let-form.

    > Adding a use for it makes the warning go away...

If the byte compiler warns about that case, it is being too ambitious.
Thus, if the value of an expression is stored into a variable, the
compiler should consider the value "used".

So if this warning really happens, it is a bug.
Can it be reproduced?




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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-23  1:01         ` Miles Bader
@ 2007-10-23 10:39           ` Richard Stallman
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Stallman @ 2007-10-23 10:39 UTC (permalink / raw)
  To: Miles Bader; +Cc: dann, ding, emacs-devel

    You should `defvar' mailp then.

It would be unclean for Gnus to put a defvar on a general short name
like `mailp'.  That is why I think this needs a total rewrite.




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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 12:13 ` Katsumi Yamaoka
  2007-10-22 18:49   ` Reiner Steib
@ 2007-10-24 19:28   ` Reiner Steib
  2007-10-24 22:18     ` Katsumi Yamaoka
  2007-10-28 16:58   ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
  2 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-24 19:28 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding, emacs-devel

On Mon, Oct 22 2007, Katsumi Yamaoka wrote:

>>>>>> Dan Nicolaescu wrote:
>> Assuming that all emacs versions that gnus wants to support have
>> either mapc or dolist, can somebody please take care of these
>> warnings?
[...]
> 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.

Thank you for working on this.  

However, you also committed it to v5-10.  As using `mapcar' is not a
bug and the changes might break the code, I'd prefer to install these
changes only in Gnus trunk (which will eventually be synced to Emacs
trunk), but not in v5-10 (and Emacs 22) unless there are other
arguments.  An argument could be to keep the code in trunk and v5-10
as close as possible.

A counter argument is that Lars suggested not to break compatibility
(with Emacs 20.7) actively:

,----[ http://thread.gmane.org/gmane.emacs.gnus.general/62286/focus=62770 ]
| Reiner Steib <reinersteib+gmane <at> imap.cc> writes:
| 
| > Do you suggest to rip out Emacs 20/XEmacs 21.1 stuff systematically
| > like it was done after the start of No Gnus (mostly by Jesper and
| > Katsumi [2]) or only drop it on occasion?
| 
| For 5.10, I think it's better to just let it decay instead of removing
| it actively.
`----

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

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-24 19:28   ` Reiner Steib
@ 2007-10-24 22:18     ` Katsumi Yamaoka
  2007-10-27 13:34       ` Purpose of Gnus CVS branches (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
  0 siblings, 1 reply; 28+ messages in thread
From: Katsumi Yamaoka @ 2007-10-24 22:18 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

>>>>> Reiner Steib wrote:

> However, you also committed it to v5-10.  As using `mapcar' is not a
> bug and the changes might break the code, I'd prefer to install these
> changes only in Gnus trunk (which will eventually be synced to Emacs
> trunk), but not in v5-10 (and Emacs 22) unless there are other
> arguments.  An argument could be to keep the code in trunk and v5-10
> as close as possible.

Oops, I misunderstood what the v5-10 branch is for.  I'll revert
the last change in the branch soon.  Thanks.

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

* Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-23 10:39         ` Richard Stallman
@ 2007-10-27 10:46           ` Reiner Steib
  2007-10-27 23:41             ` Richard Stallman
  2007-10-27 10:46           ` Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
  2007-10-28  0:05           ` Reiner Steib
  2 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-27 10:46 UTC (permalink / raw)
  To: Richard Stallman; +Cc: ding, emacs-devel

On Tue, Oct 23 2007, Richard Stallman wrote:

>     >   > (defun gnus-group-highlight-line ()
>     >   >   "Highlight the current line according to `gnus-group-highlight'."
>     [...]
>     > It seems that `mailp' is not used in that function. 
>
>     `mailp' is used implicitly through the variable `gnus-group-highlight'
>     which is let-bound to `list'.  `list' is used in the body of the
>     let-form.
[...]
> I added a `risky-local-variable' property to `gnus-group-highlight'.

Fine with me.  But I can't imagine a way to exploit this.  Setting
`gnus-group-highlight' buffer-locally (using local variables in a
file) won't effect Gnus *Group* buffer where the variable is
evaluated.

> Are there any other such variables in Gnus which contain forms to
> evaluate?

Yes, a quick «grep -inH -e ':tag "Form"' *.el» [1] showed some hits
(there are more probably).  However, I neither can see a way to
maliciously manipulate these variables through file local variables.
I someone can think of a way, please let me know.  I think the vast
majority of Gnus functions are _not_ evaluated in file-visiting
buffers.  But it's fine with me to mark all these variables as risky.

Here's a list of such variable I found so far: `gnus-button-alist',
`gnus-header-button-alist', `gnus-group-charter-alist',
`gnus-group-highlight', `gnus-group-icon-list',
`gnus-summary-highlight', `mm-charset-eval-alist'.

Bye, Reiner.

--8<---------------cut here---------------start------------->8---
-*- mode: grep; default-directory: "~/src/links/plain_No/lisp/" -*-
Grep started at Sat Oct 27 12:29:54

grep -inH -e ':tag "Form"' *.el
gnus-art.el:7181:		       (sexp :tag "Form")
gnus-art.el:7220:		       (sexp :tag "Form")
gnus.el:1482:  :type '(repeat (cons (string :tag "Hierarchy") (sexp :tag "Form"))))
gnus-group.el:384:  :type '(repeat (cons (sexp :tag "Form") face)))
gnus-group.el:422:  :type '(repeat (cons (sexp :tag "Form") file)))
gnus-sum.el:1081:  :type '(repeat (cons (sexp :tag "Form" nil)
mm-util.el:431:			     (symbol :tag "form"))))

Grep finished (matches found) at Sat Oct 27 12:29:55
--8<---------------cut here---------------end--------------->8---
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

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

* Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-23 10:39         ` Richard Stallman
  2007-10-27 10:46           ` Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
@ 2007-10-27 10:46           ` Reiner Steib
  2007-10-27 23:41             ` Richard Stallman
  2007-10-28  0:05           ` Reiner Steib
  2 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-27 10:46 UTC (permalink / raw)
  To: Richard Stallman; +Cc: ding

On Tue, Oct 23 2007, Richard Stallman wrote:

>     >   > (defun gnus-group-highlight-line ()
>     >   >   "Highlight the current line according to `gnus-group-highlight'."
>     [...]
>     > It seems that `mailp' is not used in that function. 
>
>     `mailp' is used implicitly through the variable `gnus-group-highlight'
>     which is let-bound to `list'.  `list' is used in the body of the
>     let-form.
>
> That code is a terrible crock.  Would you please rewrite it to make it
> clearer?

I'm not sure if I understand what exactly should be rewritten in this
function: The use of `mailp' through `gnus-group-highlight', the
accessing `gnus-group-highlight' through `list', both, or something
else.

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



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

* Purpose of Gnus CVS branches (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-24 22:18     ` Katsumi Yamaoka
@ 2007-10-27 13:34       ` Reiner Steib
  2007-10-29  0:36         ` Purpose of Gnus CVS branches Katsumi Yamaoka
  0 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-27 13:34 UTC (permalink / raw)
  To: ding

On Thu, Oct 25 2007, Katsumi Yamaoka wrote:

>>>>>> Reiner Steib wrote:
>> However, you also committed it to v5-10.  As using `mapcar' is not a
>> bug and the changes might break the code, I'd prefer to install these
>> changes only in Gnus trunk (which will eventually be synced to Emacs
>> trunk), but not in v5-10 (and Emacs 22) unless there are other
>> arguments.  An argument could be to keep the code in trunk and v5-10
>> as close as possible.
>
> Oops, I misunderstood what the v5-10 branch is for.  

Uh, I'm surprised if we have different understandings WRT this.  Could
you please explain?  Maybe the relevant part of texi/gnus-coding.texi
need to be more clear (it needs to be updated to explain the "Gnus
v5-10" <-> "Emacs_22 branch" sync and the future "Gnus trunk" <->
"Emacs trunk" sync).

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



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

* Re: Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-27 10:46           ` Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
@ 2007-10-27 23:41             ` Richard Stallman
  0 siblings, 0 replies; 28+ messages in thread
From: Richard Stallman @ 2007-10-27 23:41 UTC (permalink / raw)
  To: Reiner Steib; +Cc: ding

    I'm not sure if I understand what exactly should be rewritten in this
    function: The use of `mailp' through `gnus-group-highlight', the
    accessing `gnus-group-highlight' through `list', both, or something
    else.

The kludge is that the alist elements contain expressions that refer
to local variables with short names.  Perhaps write your own tiny
evaluator that handles just `and', `or', and numeric comparisons
and just a few specific variables.




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

* Re: Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-27 10:46           ` Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
@ 2007-10-27 23:41             ` Richard Stallman
  2007-10-28  0:02               ` Risky variables in Gnus Reiner Steib
  0 siblings, 1 reply; 28+ messages in thread
From: Richard Stallman @ 2007-10-27 23:41 UTC (permalink / raw)
  To: Reiner Steib; +Cc: ding, emacs-devel

      I think the vast
    majority of Gnus functions are _not_ evaluated in file-visiting
    buffers.  But it's fine with me to mark all these variables as risky.

It may be unnecessary, but we may as well do it.
Would you please do it?



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

* Re: Risky variables in Gnus
  2007-10-27 23:41             ` Richard Stallman
@ 2007-10-28  0:02               ` Reiner Steib
  2007-11-01 20:51                 ` Reiner Steib
  0 siblings, 1 reply; 28+ messages in thread
From: Reiner Steib @ 2007-10-28  0:02 UTC (permalink / raw)
  To: Richard Stallman; +Cc: ding, emacs-devel

On Sun, Oct 28 2007, Richard Stallman wrote:

>     I think the vast majority of Gnus functions are _not_ evaluated
>     in file-visiting buffers.  But it's fine with me to mark all
>     these variables as risky.
>
> It may be unnecessary, but we may as well do it.
> Would you please do it?

Yes, I will.  If anyone finds more of these, please mark them as risky
or let me know.

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

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

* Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-23 10:39         ` Richard Stallman
  2007-10-27 10:46           ` Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
  2007-10-27 10:46           ` Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
@ 2007-10-28  0:05           ` Reiner Steib
  2 siblings, 0 replies; 28+ messages in thread
From: Reiner Steib @ 2007-10-28  0:05 UTC (permalink / raw)
  To: ding

On Tue, Oct 23 2007, Richard Stallman wrote:

>     >   > (defun gnus-group-highlight-line ()
>     >   >   "Highlight the current line according to `gnus-group-highlight'."
>     [...]
>     > It seems that `mailp' is not used in that function. 
>
>     `mailp' is used implicitly through the variable `gnus-group-highlight'
>     which is let-bound to `list'.  `list' is used in the body of the
>     let-form.
>
> That code is a terrible crock.  Would you please rewrite it to make it
> clearer?

I'm not sure if I understand what exactly should be rewritten in this
function: The use of `mailp' through `gnus-group-highlight', the
accessing `gnus-group-highlight' through `list', both, or something
else.

Bye, Reiner.

P.S.: Resent to ding.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 12:13 ` Katsumi Yamaoka
  2007-10-22 18:49   ` Reiner Steib
  2007-10-24 19:28   ` Reiner Steib
@ 2007-10-28 16:58   ` Dan Nicolaescu
  2007-11-24 22:51     ` Removing obsolete `nnmail-spool-file' (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
  2 siblings, 1 reply; 28+ messages in thread
From: Dan Nicolaescu @ 2007-10-28 16:58 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: ding

Katsumi Yamaoka <yamaoka@jpl.org> writes:

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

Thanks for doing this! Can you please also get rid of the "reference
to free variable" and the "`nnmail-spool-file' is an obsolete
variable" warnings?



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

* Re: Purpose of Gnus CVS branches
  2007-10-27 13:34       ` Purpose of Gnus CVS branches (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
@ 2007-10-29  0:36         ` Katsumi Yamaoka
  0 siblings, 0 replies; 28+ messages in thread
From: Katsumi Yamaoka @ 2007-10-29  0:36 UTC (permalink / raw)
  To: ding

>>>>> Reiner Steib wrote:
> On Thu, Oct 25 2007, Katsumi Yamaoka wrote:

>> Oops, I misunderstood what the v5-10 branch is for.

> Uh, I'm surprised if we have different understandings WRT this.  Could
> you please explain?

My misunderstanding was that Emacs in the EMACS_22_BASE branch
warns about the usage of mapcar as well as the trunk.  I neglected
verifying it by building Emacs 22.1.50 then but now I have it and
I can verify that it does not warn.

> Maybe the relevant part of texi/gnus-coding.texi
> need to be more clear (it needs to be updated to explain the "Gnus
> v5-10" <-> "Emacs_22 branch" sync and the future "Gnus trunk" <->
> "Emacs trunk" sync).

Maybe it's clear on me. :)



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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-22 20:55       ` Reiner Steib
                           ` (3 preceding siblings ...)
  2007-10-23 10:39         ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Richard Stallman
@ 2007-10-31  7:46         ` Richard Stallman
  2007-10-31 20:30           ` Reiner Steib
                             ` (2 more replies)
  4 siblings, 3 replies; 28+ messages in thread
From: Richard Stallman @ 2007-10-31  7:46 UTC (permalink / raw)
  To: Reiner Steib; +Cc: dann, ding, emacs-devel

[I sent this message a week ago but did not get a response.]

    >   > (defun gnus-group-highlight-line ()
    >   >   "Highlight the current line according to `gnus-group-highlight'."
    [...]
    > It seems that `mailp' is not used in that function. 

    `mailp' is used implicitly through the variable `gnus-group-highlight'
    which is let-bound to `list'.  `list' is used in the body of the
    let-form.

    > Adding a use for it makes the warning go away...

If the byte compiler warns about that case, it is being too ambitious.
Thus, if the value of an expression is stored into a variable, the
compiler should consider the value "used".

So if this warning really happens, it is a bug.
Can it be reproduced?




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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-31  7:46         ` Richard Stallman
@ 2007-10-31 20:30           ` Reiner Steib
  2007-10-31 21:19           ` Glenn Morris
  2007-11-01  2:35           ` Katsumi Yamaoka
  2 siblings, 0 replies; 28+ messages in thread
From: Reiner Steib @ 2007-10-31 20:30 UTC (permalink / raw)
  To: Richard Stallman; +Cc: dann, ding, emacs-devel

On Wed, Oct 31 2007, Richard Stallman wrote:

>     >   > (defun gnus-group-highlight-line ()
>     >   >   "Highlight the current line according to `gnus-group-highlight'."
>     [...]
>     > It seems that `mailp' is not used in that function. 
>
>     `mailp' is used implicitly through the variable `gnus-group-highlight'
>     which is let-bound to `list'.  `list' is used in the body of the
>     let-form.
>
>     > Adding a use for it makes the warning go away...
>
> If the byte compiler warns about that case, it is being too ambitious.
> Thus, if the value of an expression is stored into a variable, the
> compiler should consider the value "used".
>
> So if this warning really happens, it is a bug.
> Can it be reproduced?

I can't reproduce it.  I just updated and bootstrapped.  There was no
warning for `gnus-group.el':

  Compiling [...]/cvs-HEAD/emacs/lisp/./gnus/gnus-group.el
  Wrote [...]/cvs-HEAD/emacs/lisp/gnus/gnus-group.elc

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

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-31  7:46         ` Richard Stallman
  2007-10-31 20:30           ` Reiner Steib
@ 2007-10-31 21:19           ` Glenn Morris
  2007-11-01  2:35           ` Katsumi Yamaoka
  2 siblings, 0 replies; 28+ messages in thread
From: Glenn Morris @ 2007-10-31 21:19 UTC (permalink / raw)
  To: rms; +Cc: dann, ding, Reiner Steib, emacs-devel

Richard Stallman wrote:

> If the byte compiler warns about that case, it is being too
> ambitious. Thus, if the value of an expression is stored into a
> variable, the compiler should consider the value "used".
>
> So if this warning really happens, it is a bug. Can it be
> reproduced?

There's nothing to worry about AFAICS:

(let ((foo (mapcar (lambda (e) e) '(a b c)))))     ; warning

(let ((foo (mapcar (lambda (e) e) '(a b c))))      ; no warning
  foo)                            

(defvar foo nil)
(defun foo-func ()
  foo)
(let ((foo (mapcar (lambda (e) e) '(a b c))))      ; no warning
  (foo-func))

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

* Re: Warning: `mapcar' called for effect; use `mapc' or `dolist'
  2007-10-31  7:46         ` Richard Stallman
  2007-10-31 20:30           ` Reiner Steib
  2007-10-31 21:19           ` Glenn Morris
@ 2007-11-01  2:35           ` Katsumi Yamaoka
  2 siblings, 0 replies; 28+ messages in thread
From: Katsumi Yamaoka @ 2007-11-01  2:35 UTC (permalink / raw)
  To: rms; +Cc: dann, ding, Reiner Steib, emacs-devel

>>>>> In http://article.gmane.org/gmane.emacs.gnus.general/65434
>>>>>	I wrote:

> For instance, `mapcar' used in `gnus-group-highlight-line'
> cannot be replaced with `mapc' even if the compiler warns it.

>>>>> In http://article.gmane.org/gmane.emacs.gnus.general/65439
>>>>>	Reiner Steib wrote:

> `mailp' is used implicitly through the variable `gnus-group-highlight'
> which is let-bound to `list'.  `list' is used in the body of the
> let-form.

>>>>> Richard Stallman wrote:

> So if this warning really happens, it is a bug.
> Can it be reproduced?

When I wrote the first message I saw that the byte compiler
warned about the usage of mapcar in `gnus-group-highlight-line',
but it has gone after I rebuilt Emacs after I wrote that message.
I also tried Emacs built with the source of two weeks ago, but it
didn't happen.  That's a mystery, but I don't intend to inquire
into it further.

Regards,

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

* Re: Risky variables in Gnus
  2007-10-28  0:02               ` Risky variables in Gnus Reiner Steib
@ 2007-11-01 20:51                 ` Reiner Steib
  0 siblings, 0 replies; 28+ messages in thread
From: Reiner Steib @ 2007-11-01 20:51 UTC (permalink / raw)
  To: Richard Stallman; +Cc: ding, emacs-devel

On Sun, Oct 28 2007, Reiner Steib wrote:

> On Sun, Oct 28 2007, Richard Stallman wrote:
>
>>     I think the vast majority of Gnus functions are _not_ evaluated
>>     in file-visiting buffers.  But it's fine with me to mark all
>>     these variables as risky.
>>
>> It may be unnecessary, but we may as well do it.
>> Would you please do it?
>
> Yes, I will.  

Done in Gnus CVS.  (Should be synced to Emacs_22 and trunk.)

> If anyone finds more of these, please mark them as risky or let me
> know.

Any suggestions?

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

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

* Removing obsolete `nnmail-spool-file' (was: Warning: `mapcar' called for effect; use `mapc' or `dolist')
  2007-10-28 16:58   ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
@ 2007-11-24 22:51     ` Reiner Steib
  0 siblings, 0 replies; 28+ messages in thread
From: Reiner Steib @ 2007-11-24 22:51 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: ding

On Sun, Oct 28 2007, Dan Nicolaescu wrote:

> Can you please also get rid of the "reference to free variable" and
> the "`nnmail-spool-file' is an obsolete variable" warnings?

As `nnmail-spool-file' has been obsolete for quite a long time, I
think it is okay to get rid of it.
See <http://article.gmane.org/gmane.emacs.gnus.commits/5531>.

Objections?

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



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

end of thread, other threads:[~2007-11-24 22:51 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-20  6:43 Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
2007-10-22 12:13 ` Katsumi Yamaoka
2007-10-22 18:49   ` Reiner Steib
2007-10-22 20:07     ` Dan Nicolaescu
2007-10-22 20:55       ` Reiner Steib
2007-10-22 21:04         ` Dan Nicolaescu
2007-10-22 21:39           ` Glenn Morris
2007-10-23  1:01         ` Miles Bader
2007-10-23 10:39           ` Richard Stallman
2007-10-23 10:39         ` Richard Stallman
2007-10-27 10:46           ` Risky variables in Gnus (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
2007-10-27 23:41             ` Richard Stallman
2007-10-28  0:02               ` Risky variables in Gnus Reiner Steib
2007-11-01 20:51                 ` Reiner Steib
2007-10-27 10:46           ` Rewriting gnus-group-highlight-line (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
2007-10-27 23:41             ` Richard Stallman
2007-10-28  0:05           ` Reiner Steib
2007-10-23 10:39         ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Richard Stallman
2007-10-31  7:46         ` Richard Stallman
2007-10-31 20:30           ` Reiner Steib
2007-10-31 21:19           ` Glenn Morris
2007-11-01  2:35           ` Katsumi Yamaoka
2007-10-24 19:28   ` Reiner Steib
2007-10-24 22:18     ` Katsumi Yamaoka
2007-10-27 13:34       ` Purpose of Gnus CVS branches (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib
2007-10-29  0:36         ` Purpose of Gnus CVS branches Katsumi Yamaoka
2007-10-28 16:58   ` Warning: `mapcar' called for effect; use `mapc' or `dolist' Dan Nicolaescu
2007-11-24 22:51     ` Removing obsolete `nnmail-spool-file' (was: Warning: `mapcar' called for effect; use `mapc' or `dolist') Reiner Steib

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 NNTP newsgroup(s).