I've been working on a custom implementation of a map called a hist-map, 
which keeps a history of additions and removals in its metadata, so that 
full diffs are not necessary.

I want to make persistent and transient versions of this map.  Both 
versions should support certain common operations, but they will also have 
some mutually exclusive methods.  I've defined the protocols like this:

*(defprotocol IHistMap*
*  (id [this]  "Get the UUID of this map.")*
*  (adds [this] "Get the additions performed on this map.")*
*  (rems [this] "Get the removals performed on this map."))*

*(defprotocol IPersistentHistMap*
*  (clear [this] "Resets additions and removals.  The map will also get a 
new ID."))*

*(defprotocol ITransientHistMap*
*  (clear! [this] "Resets additions and removals.  The map will also get a 
new ID."))*



My plan is to have a PersistentHistMap class which implements IHistMap and 
IPersistentHistMap, and a TransientHistMap class, which implements IHistMap 
and ITransientHistMap.

Somehow, this solution doesn't seem optimal.  I feel like nothing should be 
able to implement just IHistMap without providing some kind of clear 
operation, but the clear operations need to be distinguished between 
mutable and immutable types.

Is there some way to make the other two protocols "depend" on the first, or 
some other solution that I haven't thought of?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to