From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/54971 Path: main.gmane.org!not-for-mail From: sigurd@12move.de (Karl =?iso-8859-1?q?Pfl=E4sterer?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: Using CL in Gnus Date: Fri, 28 Nov 2003 17:30:54 +0100 Organization: Lemis World Sender: ding-owner@lists.math.uh.edu Message-ID: References: <87oev1uyzw.fsf@zip.com.au> <87k75oktn7.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1070037319 32130 80.91.224.253 (28 Nov 2003 16:35:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 Nov 2003 16:35:19 +0000 (UTC) Original-X-From: ding-owner+M3511@lists.math.uh.edu Fri Nov 28 17:35:15 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1APlaN-00069K-00 for ; Fri, 28 Nov 2003 17:35:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1APlYk-0004z2-00; Fri, 28 Nov 2003 10:33:34 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1APlYa-0004yu-00 for ding@lists.math.uh.edu; Fri, 28 Nov 2003 10:33:24 -0600 Original-Received: from quimby.gnus.org (quimby.gnus.org [80.91.224.244]) by justine.libertine.org (Postfix) with ESMTP id BFE833A0034 for ; Fri, 28 Nov 2003 10:33:23 -0600 (CST) Original-Received: from news by quimby.gnus.org with local (Exim 3.35 #1 (Debian)) id 1APlYZ-0007t9-00 for ; Fri, 28 Nov 2003 17:33:23 +0100 Original-To: ding@gnus.org Original-Path: wintendo.pflaesterer.de!not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 110 Original-NNTP-Posting-Host: p62.246.10.77.tisdip.tiscali.de Original-X-Trace: quimby.gnus.org 1070037202 30326 62.246.10.77 (28 Nov 2003 16:33:22 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: Fri, 28 Nov 2003 16:33:22 +0000 (UTC) X-Face: #iIcL\6>Qj/G*F@AL9T*v/R$j@7Q`6#FU&Flg6u6aVsLdWf(H$U5>:;&*>oy>jOIWgA%8w* A!V7X`\fEGoQ[@D'@i^*p3FCC6&Rg~JT/H_*MOX;"o~flADb8^ Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Hamster/2.0.4.0 Cancel-Lock: sha1:2KnRpvHf6Puhla6k4OPo4EBYS0g= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:54971 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:54971 On 27 Nov 2003, Reiner Steib <- 4.uce.03.r.s@nurfuerspam.de wrote: > On Wed, Nov 26 2003, Karl Pfl=E4sterer wrote: >> No they differ more. `mapc' can take an arbitrary number of sequences >> as arguments `mapcar' only one. > I don't doubt your explanations, but I don't understand it from the > doc-strings (GNU Emacs 21.3): > ,----[ C-h f mapc RET ] > | mapc is a built-in function. > | (mapc FUNCTION SEQUENCE) > |=20 > | Apply FUNCTION to each element of SEQUENCE for side effects only. > | Unlike `mapcar', don't accumulate the results. Return SEQUENCE. > | SEQUENCE may be a list, a vector, a bool-vector, or a string. > `---- > ,----[ C-h f mapcar RET ] > | mapcar is a built-in function. > | (mapcar FUNCTION SEQUENCE) > |=20 > | Apply FUNCTION to each element of SEQUENCE, and make a list of the resu= lts. > | The result is a list just as long as SEQUENCE. > | SEQUENCE may be a list, a vector, a bool-vector, or a string. > `---- I tried it now with an Emacs I have here (only for testing it's a precompiled version and does not really fit in my cygwin environment as I couldn't compile an Emacs under Cygwin). And here is another extremly silly difference between Emacs and XEmacs. The XEmacs `mapc' can take an arbitrary number of lists as arguments as the original CL `mapc'; the Emacs `mapc' can take only one list as argument. I can't understand why the function was written that way. Someone who knows `mapc' from CL will know that it can work on multiple lists (and in XEmacs it can). I can't iagine why soeone would want to create such a silly incompatibility. >> Furthermore IMO if you read `mapc' you know a function is used only >> for the side effects it has; on the other hand `mapcar' shouldn't be >> used for side effects IMO. > Thanks for your explanations. Is this the case in the examples of > mapc from gnus.el and gnus-agent.el? Speaking og `gnus-method-to-server' in gnus.el: IMO instead of mapc or mapcar (which would give the completely wrong intention here for a reader since the loops are only for the side effects) `dolist' could be used here. That's in cl-macs.el so could be used with eval-when-compile and for a reader is easier to see what happens (IMO). The same is true for gnus-agent.el That leads me to another point of mine. If we start No Gnus we should look for a lot of places in the code where mapping over a list is written like that: (let ((lst inputlist)) (while lst (do-something-with-list lst) . . . (setq lst (cdr lst)))) To cdr-down a list is not uncommon (above code would be nicer as recursive version) but `dolist' is IMO a much better alternative at such places. >> Better check for the Emacs version and provide a macro. People have to >> read code and the meaning of mapc is different from the one of mapcar. >> [...] >>> To make clear that the code in Gnus 5.10 _should_ not use mapc (beside >> I don't understand your point here.=20 > Well, if programmers see mapc at many places in Gnus code, they might > be tempted to use it without thinking about possible alternatives That might be true; but a programmer who doesn't think why he uses mapc instead of mapcar or dolist at a special place should not provide code for Gnus. > (alternatives w/o using CL functions). But -as we are in feature CL functions are not evil. > freeze- we will not have a significant amount of _new_ code. Thus > _if_ there is no disadvantage in using mapcar in gnus.el and > gnus-agent.el (only 4 occurrences in total, see above) we _may_ > replace them instead of providing a "compatibility hack". Think about dolist. Also if syntactilly you may use mapcar at these places, semantically it would be completely wrong. Here a famous quote I like to make my point clear: ,---- | "Programs must be written for people to read, and only incidentally | for machines to execute." | -- Abelson & Sussman, SICP (preface to the first edition) `---- KP --=20 `Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!' "Lewis Carroll" "Jabberwocky"