[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: |
Stephen J. Turnbull |
Subject: |
Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))) |
Date: |
Wed, 05 Jan 2011 13:16:51 +0900 |
Thien-Thi Nguyen writes:
> 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))))
Well, it makes me want to gag, that's all. ;-) I would not mix the
two, though (if the change is approved) you are welcome to do so.
After all, if you want the very occasional constant,
(applicating-cond
((integerp x) #'-) ; takes value
((not (listp x)) (lambda (y) 42)) ; constant function of 1 arg
((cdr x) #'car) ; takes value
((car x) ; takes value, 'cause that's how
(lambda (head) ; applicating-cond works, OK?
(code that ignores ; head
oh well
life goes on))))
Or (this is pretty disgusting, too) applicating-cond could check for
(functionp (cadr clause)), and call the function on the result of (car
clause) if that is non-nil, otherwise, return the value. I suppose
'#'car would make it possible to return #'car in that case.
> - Use a number to encode arity.
> N (EXPR N-ARY-FUNC)
>
> I think the last one is too strange, personally, but there it is.
The expansion could also use apply instead of funcall, so that the
function can be any-ary.
- 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
Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...))), Miles Bader, 2011/01/05