From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))) Date: Mon, 03 Jan 2011 11:15:11 -0500 Message-ID: References: <877hengesr.fsf@ambire.localdomain> Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: dough.gmane.org 1294072924 6318 80.91.229.12 (3 Jan 2011 16:42:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 3 Jan 2011 16:42:04 +0000 (UTC) Cc: emacs-devel@gnu.org To: Thien-Thi Nguyen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 03 17:42:00 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PZnT7-00072X-HZ for ged-emacs-devel@m.gmane.org; Mon, 03 Jan 2011 17:41:59 +0100 Original-Received: from localhost ([127.0.0.1]:33813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZn9b-0000mK-9y for ged-emacs-devel@m.gmane.org; Mon, 03 Jan 2011 11:21:03 -0500 Original-Received: from [140.186.70.92] (port=47038 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PZn4Z-00065t-8J for emacs-devel@gnu.org; Mon, 03 Jan 2011 11:15:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PZn3z-0004dz-2s for emacs-devel@gnu.org; Mon, 03 Jan 2011 11:15:16 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:35681) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PZn3y-0004du-Tn for emacs-devel@gnu.org; Mon, 03 Jan 2011 11:15:15 -0500 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1PZn3v-0000BY-5k; Mon, 03 Jan 2011 11:15:11 -0500 In-reply-to: <877hengesr.fsf@ambire.localdomain> (message from Thien-Thi Nguyen on Sun, 02 Jan 2011 22:45:56 +0100) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:134217 Archived-At: It is un-lispy for a special symbol in the middle of a list to change the way that list is used. Here's another syntax that makes it all much simpler. (cond VAR COND-CLAUSES...) would bind VAR, and set it to each clause condition after that is computed. For example, (cond temp ((cdr list) (car temp))) is equivalent to (cond ((cdr list) (car (cdr list)))) The same variable gets used for each clause, but if you want to change to a different one, just write another top-level symbol: (cond tail ((cdr list) (car tail)) first ((car list) (car first))) Only the last cond variable gets set, and not if it's nil. So you can also write this: (cond temp first nil ((setq temp (cdr list)) (car temp)) ((setq first (car list)) (car first))) That is more explicit. It is not quite as brief, but it s still better than this: (cond ((cdr list) -> (lambda (temp) (car temp))) ((car list) -> (lambda (first) (car first)))) Currently you can write this, (let (temp first) (cond ((setq temp (cdr list)) (car temp)) ((setq first (car list)) (car first)))) so the alternatives proposed above are not a tremendous improvement, just a small improvement. But even the small improvement might be good, since it improves readability. -- Richard Stallman President, Free Software Foundation 51 Franklin St Boston MA 02110 USA www.fsf.org, www.gnu.org