-
Notifications
You must be signed in to change notification settings - Fork 19
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
Need compare method on cl:hash-table #70
Comments
It's very unclear to me how to write a Some implementations, including SBCL and Franz Allegro but not Clozure, will let you specify a nonstandard hash function and test to Currently, And then there's And beyond semantics, there's an implementation difficulty. CL doesn't have hash table iterators; it only has In short, this has "can of worms" written all over it. I'm inclined to punt. |
BTW, it has always been possible for users to specify equality and comparison behavior on types FSet doesn't already support, or even override the behavior on types it does support (just be aware this will invalidate any existing collections in your session that use the type). It's easy to add methods on |
Yeah, understood about the problems and difficulty, this was always a wish-list item, and I thought I saw somewhere in FSet docs or discussion that it might be a possibility someday so I figured there was no harm in asking :-) Also noted, I use For my clojure APIs, the cl:hash-table, fset:set, and fset:map key comparison semantics are restrictive compared to the usual clojure semantics. I can live with that for now and try to document the issue ad nauseum. I expect it is likely I'll need to implement custom set/map/(mutable)hashtable classes down the road if I really want to solve it. Unsorted sets are pretty easy since all I need is the equality function (which works great with the CL lists-as-set interfaces too). Whether I really want to solve it for hash tables is another issue, but right now my hands are full with other things. On the cl:hash-table thing, and not pushing at all, but say you have an fset set and you feed it two identical hash tables with the same equality predicate. The wish is that they would compare equal instead of being treated as separate instances because they are not EQ. Again, totally understand not wanting to gum up FSet with this stuff. Will leave you in peace with thanks for the the stuff which has been working very well. |
Oops, missed that second post about order.lisp, will have a look! |
In what way? |
In pure clojure comparisons, equivalence is mostly extended to structural map equivalence, lists can be compared with vectors, and seqs will let you compare otherwise uncompariable things, e.g.
For my Common Lisp version of the APIs, the equivalence is also extended to CL hashtables, CL vectors, and CL lists, so there's a bit more combinatorics in what compares. The upshot is that in clojure "=" can hide a lot of data boundaries. |
FSet has similar functionality:
|
Obviously subjective, however given the existence of #58
it seems like the right thing to do to me (in part because I just tripped on it).
If you're supporting structural equivalence for cl:vector and other collections, excluding cl:hash-table seems inconsistent. In the example I just tripped over I had cl:hash-table types which were themselves keys in an FSet map. I was then comparing to a structurally equivalent hierarchy but one which had fset maps instead of cl:hash-tables and fset:equal? said nil.
That said, if you ever add a way for FSet users to specify equality and comparison behavior then I can do it myself. And, to the extend I'm not relying on Fset key comparison for sets and maps, I can use my own external comparison, which was punting to FSet:equal? in this case for fset types.
In my library's case, I strive for structural equivalence for all cl:list, cl:vector, cl:hash-table and fset types, as well as my own persistent list and queue types.
The text was updated successfully, but these errors were encountered: