[Top][All Lists]

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

Re: if-let and when-let: parallel or sequential

From: Harald Hanche-Olsen
Subject: Re: if-let and when-let: parallel or sequential
Date: Mon, 11 Aug 2014 18:40:24 +0200 (CEST)

[Stefan Monnier <address@hidden> (2014-08-11 14:42:19 UTC)]

> > if-let and when-let don’t make much sense with more than one binding
> > form.
> 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).

Indeed, it looks useful. But may I point out that the docstring seems
deficient? From the source code, I see that the the evaluation
short-circuits, so that evaluating

(defun foo () (insert "called foo\n") nil)
(defun bar () (insert "called bar\n") t)
(if-let ((FOO (foo))
         (BAR (bar)))
    (insert "aye\n")
  (insert (format "nope: %s\n" BAR)))


called foo
nope: nil

I can see how that is useful, but it needs to be documented better.
I'm afraid the resulting docstring may end up longer than the code,
but then so be it.

– Harald

reply via email to

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