[alexandria-devel] Re: Review cycle 1: binding constructs

Tobias C. Rittweiler tcr at freebits.de
Sat May 31 13:03:58 UTC 2008


"Nikodemus Siivola" <nikodemus at random-state.net> writes:

> I am pretty happy with all of these. (Modulo one s/IF-LET*/WHEN-LET*/
> typo I already fixed in the docstrings above.)

I'd suggest to throw them away, and implement something like Erik
Naggum's WHEREAS outside of Alexandria instead.


> Short-circuiting the evaluation in IF-LET* and WHEN-LET* has been
> proposed on occasion. I do think it is better not to, because that
> complicates the semantics slightly, and also because in the absence of
> short-circuiting anyone assuming short-circuiting behavior is going to
> notice the problem pretty much immediately, whereas should someone
> rely on _not_ short-circuiting, they might not notice the
> short-circuiting behavior which I can imagine causing subtle bugs.
> ...but if someone has a compelling use-case for short-circuiting, I am
> happy to reconsider.

In my experience short-circuiting is what you actually need far more
often.

IIUTC, when short-circuiting,


  (when-let ((foo  (frob1))
             (bar  (frob2))
             (quux (frob3))
   ..body..)

is an abbreviation for

  (let ((foo (frob1)))
    (when foo
      (let ((bar (frob2)))
        (when bar
          (let ((quux (frob3)))
            (when quux
              ..body..))))))

Which is very tedious to do manually. The non short-circuting form would
be an abbreviation for

   (let ((foo  (frob1))
         (bar  (frob2))
         (quux (frob3)))
     (when (and foo bar quux)
       ..body..))

which is less obnoxious to write manually.

  -T.




More information about the alexandria-devel mailing list