From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: Sweeter Emacs Lisp Date: Sat, 10 Aug 2013 09:27:14 -0700 (PDT) Message-ID: <56378161-1a38-40a2-bdd5-a13dc8de8d7e@default> References: <8738rh6ftk.fsf@gnu.org> <87a9lezh9w.fsf@zigzag.favinet> <8738r5zyap.fsf@zigzag.favinet> <8761vdoo3e.fsf@informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1376152060 18559 80.91.229.3 (10 Aug 2013 16:27:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 10 Aug 2013 16:27:40 +0000 (UTC) To: "Pascal J. Bourguignon" , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 10 18:27:41 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 1V8C0y-0001UC-FF for ged-emacs-devel@m.gmane.org; Sat, 10 Aug 2013 18:27:40 +0200 Original-Received: from localhost ([::1]:50185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V8C0y-0002rz-3K for ged-emacs-devel@m.gmane.org; Sat, 10 Aug 2013 12:27:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V8C0n-0002re-41 for emacs-devel@gnu.org; Sat, 10 Aug 2013 12:27:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V8C0e-0001fr-CM for emacs-devel@gnu.org; Sat, 10 Aug 2013 12:27:29 -0400 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:33388) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V8C0e-0001fK-7Q for emacs-devel@gnu.org; Sat, 10 Aug 2013 12:27:20 -0400 Original-Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r7AGRFNm030814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Aug 2013 16:27:17 GMT Original-Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7AGRDkn023862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 10 Aug 2013 16:27:14 GMT Original-Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7AGRDFh024180; Sat, 10 Aug 2013 16:27:13 GMT In-Reply-To: <8761vdoo3e.fsf@informatimago.com> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.8 (707110) [OL 12.0.6668.5000 (x86)] X-Source-IP: ucsinet22.oracle.com [156.151.31.94] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 141.146.126.69 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:162552 Archived-At: > > > RMS suggested instead: (cond VAR (CONDITION [BODY...])...) > > > > As I pointed out back then, a more general solution is a way to > > let-bind new variables in between cond clauses, as in > > (cond > > ( ) > > (let x ) > > ( )) > > > > which would be used in cases where we currently use > > (let (x) > > (cond > > ( ) > > ((progn (setq x ) ) )) >=20 > I don't like it. The general idiom in lisp, and including in emacs > lisp, is to have a close correspondance between parentheses and lexical > scope. >=20 > Whether x is in the englobing scope, or in a scope covering only the > remaining clauses, in both cases it's bad because it's not reflected by > the sexp structure of the form. +1 > In this aspect, RMS' suggestion is better. It's better, but it too is not a great idea, IMO. Clearest of all is what y'all *started* with - plain ol' lisp: (let (x) (cond ((...x...) ...) ((progn (setq x ...) ...)=20 ...))) or more likely: (cond ((let ((x ...))...) ...) ((let ((x ...))...) ...)) or typically clearer, when possible (e.g., subforms refer to the variable explicitly or do not evaluate code that refers to it): (cond ((let ((x1 ...))...) ...) ((let ((x2 ...))...) ...) depending on the need/context. > I would advise a form rather like: > (letcond > ((f) 1) > (let* ((x (g)) > (y (h x))) > ((=3D x y) 2) > ((< x y) 3) > (let ((z (p))) > ((< x z) 4)) > (t 5)) > ((q) 6) > (t 0)) > > --> (cond ((f) 1) > ((let* ((x (g)) > (y (h x))) > (cond ((=3D x y) 2) > ((< x y) 3) > ((let ((z (p))) > (cond ((< x z) 4)))) > (t 5)))) > ((q) 6) > (t 0)) Quelle horreur ! The second (the macroexpansion of the first) is more readable than the first. And the second is but a mechanical expansion. A human would write something simpler, e.g. (and (< x z) 4) instead of (cond ((< x z) 4)). And with average-length function and variable names the second form is not much more verbose than the first. Saving a few parens and explicit conditionals at the expense of clarity wrt scope etc. is usually an unwise trade-off. YAGNI.