all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnuvola.org>
To: emacs-devel@gnu.org
Subject: Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...)))
Date: Tue, 04 Jan 2011 19:12:21 +0100	[thread overview]
Message-ID: <87tyhoa67u.fsf@ambire.localdomain> (raw)
In-Reply-To: <E1PZn3v-0000BY-5k@fencepost.gnu.org> (Richard Stallman's message of "Mon, 03 Jan 2011 11:15:11 -0500")

() Richard Stallman <rms@gnu.org>
() 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:

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

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

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:

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

No variables at all!



  reply	other threads:[~2011-01-04 18:12 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-02 21:45 emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))) Thien-Thi Nguyen
2011-01-02 21:57 ` Fren Zeee
2011-01-02 22:00   ` Fwd: " Fren Zeee
2011-01-02 22:52 ` Harald Hanche-Olsen
2011-01-04 16:41   ` Thien-Thi Nguyen
2011-01-04 17:56     ` Harald Hanche-Olsen
2011-01-04 18:39       ` Thien-Thi Nguyen
2011-01-03  2:19 ` Stefan Monnier
2011-01-04 17:00   ` Thien-Thi Nguyen
2011-01-03 16:15 ` Richard Stallman
2011-01-04 18:12   ` Thien-Thi Nguyen [this message]
2011-01-05  1:55     ` Stephen J. Turnbull
2011-01-05  3:21       ` Thien-Thi Nguyen
2011-01-05  4:16         ` Stephen J. Turnbull
2011-01-05  5:15           ` Miles Bader
2011-01-05 21:29     ` Stefan Monnier
2011-01-05 22:40       ` Harald Hanche-Olsen
2011-01-06  0:10         ` Stefan Monnier
2011-01-06  8:24           ` Helmut Eller
2011-01-07  3:49             ` Stefan Monnier
2011-01-06 18:43         ` Richard Stallman
2011-01-05 23:36     ` Richard Stallman
2011-01-11 17:20       ` Andy Wingo
2011-01-05  5:17 ` Miles Bader
  -- strict thread matches above, loose matches on Subject: below --
2011-01-03  5:37 MON KEY
2011-01-04 17:20 ` Thien-Thi Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tyhoa67u.fsf@ambire.localdomain \
    --to=ttn@gnuvola.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.