it's better to use https://github.com/clojure/core.match
On Tue, Oct 25, 2011 at 11:32 AM, Ben Smith-Mannschott <[email protected]> wrote: > On Tue, Oct 25, 2011 at 11:20, Michael Jaaka > <[email protected]> wrote: >> Hi! >> Pattern matching is fine for sequence or vector destruction. >> Is is possible to destruct map and make pattern machting? >> For example I would like to make constraint for to some query service. >> It would be done as map for example: { :name "Tom" :surname "Jakarta" >> :birthDate (Date.) } or { :personalId "12312312132" } >> Then I would like to dispatch this Value Object: >> (defn service >> ([ {:keys [name surname]} ] (println "searching by personal data")) >> ([{:keys [personalId]} ] (println "searching by id"))) >> >> Why using map instead of specific type of VO? >> Because I don't want to decleare types of VO which doesn't bring any value >> to domain problem. >> Maybe matchure or other lib already implements it? > > Clojure provides only destructuring, not pattern matching. (It's my > impression that Rich is not a fan of mixing destructuring with control > flow implied by pattern matching.) > > If you want pattern matching, matchure seems like just what you need. > For your particular example, take a look at matchure's defn-match. > > https://github.com/dcolthorp/matchure > > // Ben > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- With best wishes, Alex Ott http://alexott.net/ Tiwtter: alexott_en (English), alexott (Russian) Skype: alex.ott -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
