[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

        ((cdr list) #'car)
        ((car list) #'car)


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

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

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

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

- Use top-level symbol more special in some ways, less in others.

- Use a number to encode arity.

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

reply via email to

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