[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,

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

reply via email to

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