Subject: Re: Functions in Lisp
From: (Rob Warnock)
Date: Thu, 23 Feb 2006 05:40:32 -0600
Newsgroups: comp.lang.lisp
Message-ID: <>
Thomas A. Russ <> 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 Warnock			<>
627 26th Avenue			<URL:>
San Mateo, CA 94403		(650)572-2607