[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...)))
From: |
Richard Stallman |
Subject: |
Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))) |
Date: |
Mon, 03 Jan 2011 11:15:11 -0500 |
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
- emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Thien-Thi Nguyen, 2011/01/02
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Stefan Monnier, 2011/01/02
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))),
Richard Stallman <=
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Stefan Monnier, 2011/01/05
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Harald Hanche-Olsen, 2011/01/05
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Stefan Monnier, 2011/01/05
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Helmut Eller, 2011/01/06
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Stefan Monnier, 2011/01/06