Some good examples from everyone.  Thank you.

2009/6/3 Richard Newman <holyg...@gmail.com>

>
> Some work in which I'm currently engaged uses ad hoc hierarchies for
> dispatching on a handler and either a message method or a method and
> response code. In the realm of HTTP clients -- imagine that the
> response arrives as a method invocation -- the equivalent would be
> writing something like
>
> (defmethod do-response [MyHandler :post :ok]
>  ;; Handle a success response to my POST request
>  )
>
> (defmethod do-response [MyHandler :any-method :failure]
>  ;; Handle any kind of failure response to any method (GET, POST,
> PUT...).
>  )
>
> The dispatch function can introspect the message itself to extract the
> method, code, etc. etc. -- this is basically polymorphism over any
> facet of the arguments, with full programmatic power to extract those
> facets. Most importantly, applications can themselves augment the
> hierarchy to include meaningful groupings -- in my example above, the
> various methods all derive from :any-method, and you could easily
> imagine a server having a :methods-i-cant-handle node in its
> hierarchy, making that piece of logic explicit in the tree.
>
> This example doesn't look that compelling, except that my real domain
> has a rich hierarchy of message and response types, which allows a
> great deal of abstraction in message handling.
>
> (I hope one day to be able to unveil what I'm doing. It's not that
> innovative, but it's not done yet!)
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to