From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Pascal J. Bourguignon" Newsgroups: gmane.emacs.devel Subject: Re: Lexical let and setq Date: Sat, 14 Sep 2013 16:04:44 +0200 Organization: Informatimago Message-ID: <878uyza48z.fsf@informatimago.com> References: <871u51ll93.fsf@yandex.ru> <0b29ebee-8ed4-47e2-816b-910a013a0898@default> <878uz0e02m.fsf_-_@maru2.md5i.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1379167604 5396 80.91.229.3 (14 Sep 2013 14:06:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 14 Sep 2013 14:06:44 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 14 16:06:48 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VKqUj-0005PL-Rh for ged-emacs-devel@m.gmane.org; Sat, 14 Sep 2013 16:06:42 +0200 Original-Received: from localhost ([::1]:53470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKqUj-0006qs-CZ for ged-emacs-devel@m.gmane.org; Sat, 14 Sep 2013 10:06:41 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKqUb-0006qd-Nl for emacs-devel@gnu.org; Sat, 14 Sep 2013 10:06:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKqUV-0003L9-Oj for emacs-devel@gnu.org; Sat, 14 Sep 2013 10:06:33 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:60383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKqUV-0003Kp-I6 for emacs-devel@gnu.org; Sat, 14 Sep 2013 10:06:27 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VKqUS-0005Ao-UC for emacs-devel@gnu.org; Sat, 14 Sep 2013 16:06:24 +0200 Original-Received: from amontsouris-651-1-99-185.w82-123.abo.wanadoo.fr ([82.123.118.185]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Sep 2013 16:06:24 +0200 Original-Received: from pjb by amontsouris-651-1-99-185.w82-123.abo.wanadoo.fr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 14 Sep 2013 16:06:24 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 89 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: amontsouris-651-1-99-185.w82-123.abo.wanadoo.fr Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:Mzc1NjZlMjIxYTU2NDZiODBmNmFmODFmNDM1YjVhNDJlOTQ4NjJjMQ== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163339 Archived-At: Lars Magne Ingebrigtsen writes: > Stefan Monnier writes: > >> That one is OK, since recursion is not supported efficiently. >> The problem is when people use the above because they're writing (poor) >> C code in Elisp (e.g. they begin their functions with a big let >> declaring all the local vars that they may use later on in the >> function). > > I think the most common reason for stashing a lot of variables in a let > is to avoid infinite indentation. > > (let ((a (foo))) > (something) > (let ((b (something-else))) > (more a b) > (let ((c (yet-more))) > (zot a b c)))) > > vs > > (let ((a (foo)) > b c) > (something) > (setq b (something-else)) > (more a b) > (setq c (yet-more)) > (zot a b c)) > > I kinda think the latter form is sometimes more readable. Err, no. A form with less indentation MAY be more readable, but not when it's a procedural form with a setq every other subform. If something similar and systematicall occurs from one level of indentation to the other, then you can write a macro that will do this uniform something, and have a unindented body: (something-similar (foo) (something) (something-else) (more) (yet-more) (zot)) A simple example would be: (defmacro pipe (input &rest functions) (pipe-aux input functions)) (defun pipe-aux (input functions) (if functions (pipe-aux (list (first functions) input) (rest functions)) input)) (macroexpand '(pipe foo a b c d e f g)) ; --> (g (f (e (d (c (b (a foo))))))) So you just write (pipe foo a b c d e f g) or rather: (pipe foo a b c d e f g) But in case of your let, it is much harder to read, because now you must rebuild the data flow from the variables and setq expressions. The indented form was much clearer, because you can more easily skip a subexpression, knowing for sure that whatever happens to variables in subexpressions can't affect the rest. -- __Pascal Bourguignon__ http://www.informatimago.com/