So let's back up a bit and take a look at your assumptions. In your
previous post you stated ", I kept thinking about why I am avoiding
protocols. In general, I very much like having abstractions. But I find
that even small abstractions tend to complect what with how."

I would love to see an example of this in code.

I tend to agree with some other people here, I think you're so far out in
the weeds with this approach that you haven't realized that one of your
starting assumptions could be incorrect. You state that protocols and
multimethods complicate refactoring, can you show us an example?

Timothy



On Tue, Nov 24, 2015 at 7:37 AM, William la Forge <laforg...@gmail.com>
wrote:

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



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

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