[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

      ((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:

      ((cdr list) (car tail))
      ((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:

      ((cdr list) -> (lambda (temp) (car temp)))
      ((car list) -> (lambda (first) (car first))))

Currently you can write this,

    (let (temp first)
        ((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
www.fsf.org, www.gnu.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]