1) would be more:
 - define a protocol for each kind of function (render, serialize...)
- define a deftype/defrecord for each type of element, and make them extend
the protocol

It's not that different from 2. (protocol, as far as I understand, are
multimethod whose dispatch function is the type of first arg)

More choice:

3)

(defn render "rendering"
   [obj context]
  (case (:shape obj)
     :line (render-line obj context)
   .....
)

with obj being a PersistentHashMap {:shape :line :begin {:x :y} ...}

The right choice depends somehow of taste.

I would do for 1, but other would do differently I think.
Good thing with a multi-paradigm language.

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