unofficial mirror of emacs-devel@gnu.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: Wed, 05 Jan 2011 04:21:55 +0100	[thread overview]
Message-ID: <87tyhot4q4.fsf@ambire.localdomain> (raw)
In-Reply-To: <878vz0i06n.fsf@uwakimon.sk.tsukuba.ac.jp> (Stephen J. Turnbull's message of "Wed, 05 Jan 2011 10:55:28 +0900")

() "Stephen J. Turnbull" <stephen@xemacs.org>
() Wed, 05 Jan 2011 10:55:28 +0900

   All these occur in a top-level form, though.

Usually, yes.

    > - Functional style is not unlispy.

   True, but in the examples so far you could define a macro like

   (defmacro applificating-cond (&rest clauses) ...)

   and write

      (applificating-cond 
        ((cdr list) #'car)
        ((car list) #'car)

   No?

Yes, but now traditional ‘cond’ clauses cannot be used within
‘applificating-cond’.  The ‘=>’ serves to distinguish between
those clauses requiring the EXPR value and those that don't.
Which brings us to:

   So, do you ever want to write

      (cond 
        ((cdr list) => #'car)
        ((car list) (random-expr-not-needing-value-of-car-list free-var))

   or the like?  (That makes me feel a little ill, but YMMV.)

Sure, why not?  Good fences make good neighbors, and the price
of this flexible neighborliness (or neighborly flexibility) is
syntax.

(cond
  ((integerp x) => #'-)             ; takes value
  ((not (listp x)) 42)              ; traditional
  ((cdr x) => #'car)                ; takes value
  ((car x)                          ; takes value, unnecessarily
   => (lambda (head)
        (code that ignores ; head
         oh well
         life goes on))))

There are other ways to distinguish between these two clause
variants, of course.  Doodling out loud:

- Move special symbol to head of clause.
  (=> EXPR 1-ARY-FUNC)

- Use vectors.
  [EXPR 1-ARY-FUNC]

- Use top-level special symbol.
  => (EXPR 1-ARY-FUNC)

- Use top-level symbol more special in some ways, less in others.
  t (EXPR 1-ARY-FUNC)

- Use a number to encode arity.
  N (EXPR N-ARY-FUNC)

I think the last one is too strange, personally, but there it is.



  reply	other threads:[~2011-01-05  3:21 UTC|newest]

Thread overview: 25+ 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: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
2011-01-05  1:55     ` Stephen J. Turnbull
2011-01-05  3:21       ` Thien-Thi Nguyen [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87tyhot4q4.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).