On Tue, Mar 15, 2011 at 12:58 PM, Armando Blancas
<armando_blan...@yahoo.com> wrote:
> Another choice is to construct shapes as closures with auto-dispatch.
> So a circle could be made thus, with no data structure per se:
>
> (defn make-circle [x y r]
>  (fn [method]
>    (case method
>      :draw (fn [color] ...)
>      :rotate (fn [degrees] ...)
>      :r (fn [] r)
>      :x (fn [] x)
>      :y (fn [] y))))

And then, of course, there's this Smalltalkesque dispatch model. All
it needs to complete the picture are a couple of default cases:

:DoesNotUnderstand (throw
                     (IllegalArgumentException.
                       (str
                         "make-circle DoesNotUnderstand: "
                         method)))
(recur :DoesNotUnderstand)

:)

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