Alex/Rich, if a patch is welcome for this I am happy to raise a ticket and
submit.
Test case:
(clojure.data/diff {:x {:y 1}} {:x {}})
Expected:
({:x {:y 1}} nil nil)
Actual:
;; => ({:x {:y 1}} {:x nil} nil)
Problem:
There is nothing only in the second input, so the second result should be
nil.
{:x nil} implies that there is a nil in the second input, which there is
not.
Furthermore the result cannot distinguish from
(clojure.data/diff {:x {:y 1}} {:x nil})
Which should and does correctly return {:x nil} as the second result.
Affects:
Empty collections in first or second argument
Cause:
clojure.data/diff-associative-key
[(when (and in-a (or (not (nil? a*)) (not same))) {k a*})
(when (and in-b (or (not (nil? b*)) (not same))) {k b*})
(when same {k ab})]
should be
[(when (and in-a (or (not (nil? a*)) (and (not same) (nil? va)))) {k
a*})
(when (and in-b (or (not (nil? b*)) (and (not same) (nil? vb)))) {k
b*})
(when same {k ab})]))
Why do I care?:
I use and maintain a modest library to send state changes from Clojure to
ClojureScript
https://github.com/timothypratley/patchin
In this context, handling empty collections/nils is desirable so the data
can be treated abstractly.
I have a workaround, so am not affected by the issue, just providing a
motivating example where knowing the difference is useful.
Regards,
Timothy
--
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.