From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: dolist considered harmful Date: Tue, 30 Oct 2018 21:31:18 +0200 Message-ID: <83ftwnjkop.fsf@gnu.org> References: NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1540927758 24927 195.159.176.226 (30 Oct 2018 19:29:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Oct 2018 19:29:18 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 30 20:29:13 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 1gHZhM-0006FI-PV for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 20:29:08 +0100 Original-Received: from localhost ([::1]:55135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHZjT-0005MW-1E for ged-emacs-devel@m.gmane.org; Tue, 30 Oct 2018 15:31:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHZjM-0005LK-JB for emacs-devel@gnu.org; Tue, 30 Oct 2018 15:31:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHZjJ-0007l6-BC for emacs-devel@gnu.org; Tue, 30 Oct 2018 15:31:12 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHZjJ-0007kv-6K; Tue, 30 Oct 2018 15:31:09 -0400 Original-Received: from [176.228.60.248] (port=1040 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gHZjI-0007uj-Lw; Tue, 30 Oct 2018 15:31:09 -0400 In-reply-to: (message from Stefan Monnier on Tue, 30 Oct 2018 14:39:46 -0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e 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:230850 Archived-At: > From: Stefan Monnier > Date: Tue, 30 Oct 2018 14:39:46 -0400 > > - 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. I think the rest of the doc string explains how. > "evaluate" is unclear (is it passed to `eval`? Then why not say it? What "evaluation" is, is described in the section "Evaluation" of the ELisp manual. > Also, in which order? It says "each car from LIST, in turn". I think this answers your question. > 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? I think this is clear from the text, I'm unsure what confused you. > - 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? There's no contradiction here. > 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. Patches welcome.