[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: Thien-Thi Nguyen
Subject: Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...)))
Date: Tue, 04 Jan 2011 19:12:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

() Richard Stallman <address@hidden>
() 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.

Hmm.  I guess that this is the same grounds for your
unease with keyword arguments.  Close?  My take on the
lispiness of this change is:

- We are already dealing with a construct where the
  treatment of the list is non-uniform (EXPR vs BODY),
  so playing in the "neck" area has precedence: special
  handling of docstring, ‘interactive’ form, indentation
  hints (for ‘defmacro’), etc.

- Functional style is not unlispy.  It's true that a
  large body of Emacs Lisp is written with assignments
  (and will continue to be done that way), but that is
  hardly elegant.  It would be nice to bolster this
  argument with "and hardly needed", supplying stats
  gathered from lisp/* on how often a local variable is
  declared only to be used in communication between a
  cond's EXPR and BODY forms, but i haven't done that,
  yet.  (Anyone want to beat me to it?)

Having said that, i readily admit my relative inexperience
with Lisp (Emacs Lisp or otherwise).  It could be that what i
hold dear as lispy is actually more schemey than anything...
Now for some thoughts on:

   Here's another syntax that makes it all much simpler.

       (cond VAR COND-CLAUSES...)


   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)))

Really, what i want to do is elide variable names entirely,
for what i regard as essentially an internal (to each clause)
affair.  Any communication outside of that scope is a lose
(or rather, is the status quo, which is less than winning).

   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.

I should clarify.  The original proposal should read:

  (cond (EXPR => 1-ARY-FUNC) ...)

In other words, the (lambda (VAR) ...) does the job,
but is not required.  So, the example expression you
gave above can actually be made even more succinct:

    ((cdr list) => #'car)
    ((car list) => #'car)

No variables at all!

reply via email to

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