From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: Sweeter Emacs Lisp Date: Tue, 23 Jul 2013 06:37:50 +0200 Message-ID: <8738r5zyap.fsf@zigzag.favinet> References: <8738rh6ftk.fsf@gnu.org> <87a9lezh9w.fsf@zigzag.favinet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1374554116 10127 80.91.229.3 (23 Jul 2013 04:35:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 23 Jul 2013 04:35:16 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jul 23 06:35:17 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 1V1UJh-0001vT-GG for ged-emacs-devel@m.gmane.org; Tue, 23 Jul 2013 06:35:17 +0200 Original-Received: from localhost ([::1]:54647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1UJh-0004uD-0U for ged-emacs-devel@m.gmane.org; Tue, 23 Jul 2013 00:35:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1UJc-0004tf-St for emacs-devel@gnu.org; Tue, 23 Jul 2013 00:35:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1UJb-0005ZR-HL for emacs-devel@gnu.org; Tue, 23 Jul 2013 00:35:12 -0400 Original-Received: from smtp207.alice.it ([82.57.200.103]:47723) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1UJb-0005W5-5r for emacs-devel@gnu.org; Tue, 23 Jul 2013 00:35:11 -0400 Original-Received: from zigzag.favinet (95.236.25.26) by smtp207.alice.it (8.6.060.26) id 51DA965502C3CEFE for emacs-devel@gnu.org; Tue, 23 Jul 2013 06:35:09 +0200 Original-Received: from ttn by zigzag.favinet with local (Exim 4.72) (envelope-from ) id 1V1UMK-0006Kh-Tk for emacs-devel@gnu.org; Tue, 23 Jul 2013 06:38:01 +0200 Mail-Followup-To: emacs-devel@gnu.org In-Reply-To: (Stefan Monnier's message of "Mon, 22 Jul 2013 17:04:04 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.103 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:162083 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable () Stefan Monnier () Mon, 22 Jul 2013 17:04:04 -0400 > 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 ) ) )) Yes, i see this can be used as the basis of the other forms. Cool. Has anyone done a C implementation? Here's a sketch (in *scratch*): (defmacro cool-cond (&rest clauses) (let ((rev (reverse clauses)) one elab) (while (setq one (pop rev)) (setq elab (pcase one (`(let ,var ,exp) `((t (let ((,var ,exp)) (cond ,@elab))))) (`(let ,var) `((t (let (,var) (cond ,@elab))))) (_ (cons one elab))))) `(cond ,@elab))) =20 (macroexpand '(cool-cond (nil t)=20 (t nil))) (cond (nil t) (t nil)) =20 (macroexpand '(cool-cond (let bar 'none) (nil t)=20 (let foo (list bar 42)) (foo) (t nil))) (cond (t (let ((bar 'none)) (cond (nil t) (t (let ((foo (list bar 42))) (cond (foo) (t nil)))))))) =2D-=20 Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) =3D> nil --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAlHuCKEACgkQZwMiJEyAdQLG4wCeMC6w6yGhHg+iuM0+ZL5lUGMy njoAoMzwFy06uUgyEZo+FjdJ+lKA/TV8 =4hRj -----END PGP SIGNATURE----- --=-=-=--