[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: |
Wed, 05 Jan 2011 04:21:55 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
() "Stephen J. Turnbull" <address@hidden>
() 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.
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), (continued)
- 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, 2011/01/03
- 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
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Richard Stallman, 2011/01/06
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Richard Stallman, 2011/01/05
- Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Andy Wingo, 2011/01/11