If-let would be confusing if it handled multiple bindings, since you wouldn't know how much had succeeded when you executed the else branch. That doesn't apply to when-let; fortunately it's quite simple to write one that does do multiple bindings in terms of the existing when-let, and it would be very similar to the maybe monad. It still would not be the maybe monad for the same reason that the existing "maybe-m" in the monads library isn't actually the maybe monad: without a Just-like wrapper meaning "success", it's impossible to successfully return nil.
Sent from my iPhone On Dec 30, 2012, at 11:56 AM, Mark Engelberg <mark.engelb...@gmail.com> wrote: > On Sun, Dec 30, 2012 at 4:32 AM, Meikel Brandmeyer <m...@kotka.de> wrote: > (when-let [s (seq coll)] > (do-stuff-with s)) > > I would find when-let a lot more useful if it worked with multiple bindings, > e.g., > (when-let [x blah1 > y blah2 > z blah3] > (+ x y z)) > should shortcut return nil if any of x, y, z evaluate to falsey. > > Actually, I usually use Christophe Grand's version of when-let and if-let > which handle this. I find it to be more useful that way. > > Any idea why core's when-let/if-let don't behave this way? I've been looking > through the monad material lately, and it seems like let is the identity > monad, for is the sequence monad, and when-let wants to be the maybe monad, > but isn't quite because it only handles one binding. Doesn't it seem most > natural to let it handle multiple bindings? What am I missing? > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en