Subject: Re: Functions in Lisp
From: rpw3@rpw3.org (Rob Warnock)
Date: Thu, 23 Feb 2006 05:40:32 -0600
Newsgroups: comp.lang.lisp
Message-ID: <-JOdnW19DJatAmDeRVn-ig@speakeasy.net>
Thomas A. Russ <tar@sevak.isi.edu> wrote:
+---------------
| Well, you may disagree with this usage, but I have seen this used for
| situations where you have a series of attempts to create something, with
| failure being signaled by NIL, and a desire to avoid multiple calls to
| an expensive function:
| 
| (let ((value nil))
|   (cond ((setf value (try-to-make-foo arg1 arg2))
|          (do-something-with value))
|         ((setf value (try-to-make-bar arg1 arg2))
|          (do-something-with value))
|         ((setf value (try-to-make-bar arg1 arg2))
|          (do-something-with value))))
+---------------

By analogy to the WHEN-vs-AND subthread, I'd probably write that
[assuming the 2nd BAR should have been BAZ] this way:  ;-}

    (do-something-with (or (try-to-make-foo arg1 arg2)
			   (try-to-make-bar arg1 arg2)
			   (try-to-make-baz arg1 arg2)
			   (error "Mumble...")))


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607