On Mon, Oct 10, 2011 at 09:08:42AM -0700, Daniel Pittman wrote: > So, I have one other argument in favour of "just return nil", which I > prefer: > > If you just return il, I can use :else to throw fairly cheaply, and > quite visibly. > > If you throw then I have to wrap any non-exhaustive pattern in a > try/catch block to avoid the exception propagating up the stack. > > Daniel
An :else clause *makes* for an exhaustive pattern; :else nil will never throw an exception, and shows the intention to expliclty handle unknown values by returning nil. I think a match-debug is barking up the wrong tree. If throwing an exception is the right thing to do to track down an unaccounted case, why make a different macro just for a slightly different default behavior that is easily specifiable by :else. In fact, the match macro can simply implement default behavior by "adding an :else clause if there is none" (thus removing concerns about 'code size'). I would definitely consider it a plus for the stock vector form to work on any seqable, especially when using match to write macros. Right now I've been doing (match-1 (into [] ...) ...) just to make the clauses look nicer. If the type of the seqable is important to differentiate or for performance, then there's more complex :seq and :vector. Also, what's the point of having a specific match and match-1? I presume it's to avoid creating an intermediate vector. Why not make match-1 the default, and if the expression is a literal vector, fall back to current match? Steve -- 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