From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: dolist considered harmful Date: Tue, 30 Oct 2018 14:39:46 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1540924681 24625 195.159.176.226 (30 Oct 2018 18:38:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 18:38:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 19:37:57 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHYto-0006EW-43 for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 19:37:56 +0100 Original-Received: from localhost ([::1]:54970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHYvu-0000vt-3Q for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 14:40:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHYvj-0000vm-6c for emacs-devel@gnu.org; Tue, 30 Oct 2018 14:39:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHYvd-0004JA-4E for emacs-devel@gnu.org; Tue, 30 Oct 2018 14:39:55 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:36577) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHYvc-0004Hm-SP for emacs-devel@gnu.org; Tue, 30 Oct 2018 14:39:48 -0400 Original-Received: from pastel.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w9UIdl3E012832; Tue, 30 Oct 2018 14:39:47 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id DDA126A47D; Tue, 30 Oct 2018 14:39:46 -0400 (EDT) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6407=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6407> : inlines <6948> : streams <1802833> : uri <2741204> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230844 Archived-At: All this pcase-dolist discussion made me take a second look at dolist and now I wondering whether we should keep it: - The docstring is incomprehensible: Loop over a list. Evaluate BODY with VAR bound to each car from LIST, in turn. Then evaluate RESULT to get return value, default nil. I don't know how to loop over a list. Did they mean to set the cdr of the last element so it loops back to the first element? "evaluate" is unclear (is it passed to `eval`? Then why not say it? What second arg is passed to `eval`?). but why evaluate it several times? Also, in which order? How does RESULT communicate the return value? Is it RESULT which defaults to nil or the return value? If the return value, then when does it default to nil? - The docstring says nothing of what happens when LIST is not a list, yet a quick grep shows that most uses of dolist use for LIST a simple variable rather than a list. What gives? Since it can only be used when we're 100% sure that LIST is a LIST, (and who can be sure of such a thing in a dynamic language like Emacs Lisp), I think we'd be better off deprecating it and changing all uses of dolist with a clear while+cdr loop that everyone can understand. Stefan