Subject: Re: I like WHEN/UNLESS Was: Promoting CL Was: What I want from my Common   Lisp vendor and the Common Lisp community
From: Erik Naggum <erik@naggum.net>
Date: Thu, 06 Sep 2001 01:06:50 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3208727206846415@naggum.net>

* Thomas F. Burdick
> Do you use the variation that unconditionally binds the result of the
> predicate to THIS (or something similar)?  That drives me nuts,
> personally, so I use IF-LET:
> 
>   (if-let (damn-thang (find-the-damn-thang))
>           (do-the-damn-thang damn-thang)
>           (do-something-else))
> 
> which I like much better.

  While binding and testing at the same time is useful, I find that I
  either want it to be bound first and tested independently

(let ((damn-thang (find-the-damn-thang)))
  (if damn-thang
    (do-the-damn-thang damn-thang)
    (do-something-else)))

  or assigned to in the test

(let ((damn-thang))
  (if (setq damn-thang (find-the-damn-thang))
    (do-the-damn-thang damn-thang)
    (do-something-else)))

  or using more advanced control-flow mechanisms, more suitable when there
  is no else branch and much more going on, such as an already established
  block surrounding the forms at the appropriate level

(block nil
  (do-the-damn-thang (or (find-the-damn-thang) (return))))

///