On Mon, Mar 19, 2012 at 3:56 AM, Narvius <narv...@gmail.com> wrote: > 2) Return [new-state success?] instead of just new-state - requires too much > acrobatics from the user of the function (which is still me, but whatever).
Destructuring makes it easy to work with multi-value returns: (let [[state status] (make-move old-state)] (if status (do-stuff-with state) (println "move failed"))) More likely tho' I suspect you might want to return a specific failure: [new-state nil] - state changed successfully [old-state some-failure] - state failed to change because of that failure (which might be a string or some more complex description) In general, you may just want to get the (same or updated) state back and then continue to process it, reporting errors as you go? Something like this: (loop [state initial-state] (let [[new-state failure] (change-world state)] (when failure (println "ERROR:" failure)) (recur new-state)) As others have indicated, there are many possible solutions... -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- 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