Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strengthen types of some update methods #3

Closed
wants to merge 3 commits into from

Conversation

jordanlewis
Copy link
Contributor

A number of the public collection modification methods were returning the type of their interface, rather than their concrete type.

For example, PersistentTreeSet.cons returned IPersistentSet, even though it always returns a PersistentTreeSet. This property makes these data structures a lot harder to work with in Java, as users must continually cast return values of these methods.

Attached commits strengthen the return types of such methods.

The assoc, assocEx, and without methods of PersistentHashMap and
PersistentStructMap both returned IPersistentMaps, when in fact they can
return their own type. This makes the structures more pleasant to use,
as one can rightly expect to get back a PersistentHashMap from the assoc
method of another PersistentHashMap.
Similar to last commit. PersistentHashSet and PersistentTreeSet were
returning IPersistentSets when they could be returning
PersistentHashSets and PersistentTreeSet.
@krukow
Copy link
Owner

krukow commented Jun 29, 2012

I understand your concern however I would not deviate from Rich Hickeys choice of return types. For example PersistentTreeSet cons returns IPersistentSet to retain freedom to return a different (ordered set) implementation.

I appreciate the effort to pull back changes into clj-ds, but I prefer not to pull in this one. If you need this type strengthening I recommend you run off your local fork.

@krukow krukow closed this Jun 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants