So lets look at some artifacts then. I think we need an interface that all
composites implement:

(definterface Composite
  (compositeMap []))

The function composite-map returns the map which holds the aggregated
functions and data.

Now lets look at a sample function, blip:

(def blip [^Composite this x y z] ((:blip (.compositeMap this)) this x y z))

and a protocol that includes blip:

(defprotocol gran
  (blip ^Composite this x y z))

Next we define a type which will hold an aggregate that includes an
implementation of blip:

(deftype wackel [my-map]
  Composite
  (defn compositeMap [_] my-map))

and a function to create an instance of that type:

(defn new-wackel [this opts] (assoc opts :blip (fn [this x y z] (+ x y z)))

Finally, we can extend our type with the protocol:

(extend wackel
  gran
  {:blip blip})

I find this uncomfortable. In Rich's terms this is simple but hard. To be
expected, as it is a major decomplection. But it will take me a while to
get comfortable with this. :-(

--b

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to