[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: if-let and when-let: parallel or sequential
From: |
Lars Magne Ingebrigtsen |
Subject: |
Re: if-let and when-let: parallel or sequential |
Date: |
Tue, 12 Aug 2014 04:43:34 +0200 |
User-agent: |
Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
> Why do you think so? If they only work for a single binding, the
> benefit is really minor. It's only when you use several bindings that
> the benefit becomes more significant (the alternative being either
> a very deeply nested code, or separating the var's declarations from
> their initialization).
I use lw:when-let all the time in Common Lisp. It only takes a single
binding. I find it very clear and nice -- mostly used as a kinda "early
return" thing, but without the return.
(defun foo (zot)
(when-let (bar (compute-something zot))
...))
I grepped through a random directory in our code base, and out of 146
uses of when-let, 6 had nested when-lets.
There's lw:when-let*, though, which is like Emacs' when-let (i.e.,
several bindings), which is used two times.
Anyway, I think Emacs' when-let is a good addition as it is now. Even
if the multiple-let-binding version doesn't get used much, it's nice
when you need it.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no