[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if-let and when-let: parallel or sequential
From: |
John Mastro |
Subject: |
Re: if-let and when-let: parallel or sequential |
Date: |
Mon, 11 Aug 2014 20:30:36 -0700 |
Richard Stallman <address@hidden> wrote:
> With several sequential bindings, the alternative is
>
> (let* ...bindings...
> (if ...))
>
> Thus, if-let saves just one level of nesting
> even if there are several bindings.
The current implementation in trunk is actually short-circuiting. So the
equivalent to:
(when-let ((a (foo))
(b (bar)))
b)
Would be:
(let ((a (foo)))
(when a
(let ((b (bar)))
b)))
And so on.
The only non-Clojure variant of these that I'm really familiar with is
Alexandria's[1]. It has both `-let' and `-let*' versions, allows
multiple bindings, and is not short circuiting. (I don't say this to
suggest we should mimic them, just to expose "where I'm coming from").
Anyway, I agree with Bozhidar that they'll be nice to have regardless of
the particulars, so I'll gracefully bow out :)
[1]
http://common-lisp.net/gitweb?p=projects/alexandria/alexandria.git;a=blob;f=binding.lisp
--
john