emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...)))


From: Stefan Monnier
Subject: Re: emacs lisp syntax rfc: (cond (EXPR => (lambda (X) ...)))
Date: Wed, 05 Jan 2011 16:29:30 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> - Functional style is not unlispy.  It's true that a

Agreed, and as a functional programmer (and implementer of functional
programming languages) the fact that the proposed cond => thingy is
naturally pure is an important aspect.  Richard's proposal fails pretty
poorly there.  Yet, Richard's proposal solves another problem as well:
often the value is needed not just for the body of a cond branch, but
also for subsequent branches (because the value is used in several of
the conditions, but not all (and more importantly not the first), so you
can't (or don't want to for efficiency reasons) lift it to before the
cond, yet you do want to share it between branches).

An alternative would be to add a way for a cond test to add a variable
so it's available to the cond's body and to subsequent branches, i.e.
a let in the middle of the cond.


  (cond
   (foo bar)
   ((special-let ((var exp1)) exp2) bla... exp1 ...bla)
   (bli... exp1 ...bli) ...)

Such a thing could still be pure, while providing more flexibility than
Richard's (since the var doesn't have to take the value returned as the
condition, but can take the value of any sub-expression needed to
compute that condition).


        Stefan



reply via email to

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