On Sun, Feb 15, 2009 at 10:50 PM, David Nolen <dnolen.li...@gmail.com> wrote: > Would it be possible to make the arguments to handle be optional? Is this a > good or bad idea?
(kit/with-handler (vec (map int-half [2 4 5 8])) (kit/handle *odd-number-error* [n] (throw (Exception. (format "Odd number %d in vector." n))))) The args vector ([n] above) is actually a vector in a :keys destructuring expression, so its elements are option. In fact map being destructured has several other bit of information that may be useful. You can see them like this: (kit/with-handler (vec (map int-half [2 4 5 8])) (kit/handle *odd-number-error* {:as err} err)) -> {:n 5, :tag user/*odd-number-error*, :msg "Can't handle odd number: 5", :unhandled #<...>} That map includes values inherited from parent error types. So you can definitely leave the args vector empty. I think it might be more confusing that useful to allow leaving out the args vector entirely. Currently the expressions after the args vector are expanded into an implicit 'do', so you can have as many as you'd like. Detecting whether the first expression after the error name is a vector (or map) and so should be treated as args vs. a list to be an evaluated expression seems potentially confusing. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---