hrldcpr / pcollections

A Persistent Java Collections Library
Other
765 stars 79 forks source link

org.pcollections.PMap should not extend java.util.Map #78

Closed ghost closed 5 years ago

ghost commented 5 years ago

From my point of view, it's confusing to be able to call java.util.Map methods from PMap. They shouldn't be exposed to the final user.

Every public method on PMap has to return another PMap

What do you think?

hrldcpr commented 5 years ago

Hi Rafael!

I agree this can be confusing, but I think the benefit of being able to interoperate with code and libraries that weren't written for PCollections makes it worth the tradeoff. I.e. being able to pass a PMap into any code that expects a Map, as long as it doesn't try to mutate it.

(And all of Java Collections interfaces do specify that mutation operations are optional, so PMap really is a valid Map subtype.)

I hope that seems reasonable to you, thanks for the input