@dmiller Hi! This may or may not be a bug. One of our developers stumbled on this a few weeks ago. I am not sure he brought it to your attention. Please let us know if we are neglecting something. This is not an critical issue for us since we have a workaround. But I thought we should bring it up here since we do not have Jira accounts. Verbatim from our source comments ...
In CLR: sorted-map-by is broken. It seems to want a .compare method that doesn't exist.:
-; to reproduce: (subseq (assoc (sorted-map-by compare) "a" 42) < "d")
:
-; > error: something something ".compare not found"
:
-; The answer is to pass a class that has both .compare and .Compare.
:
-; so this works:
:
-; (definterface LowerCaseComparer (compare [a b]))
:
-; (subseq (assoc (sorted-map-by (proxy [LowerCaseComparer System.Collections.IComparer] [:
] (compare [a b] (clojure.core/compare a b)) (Compare [a b] (clojure.core/compare a b)))) :
"a" 42) < "d")@bediako.george598 out of curiosity, are you using Clojure with CLR in production, or are you just playing around?
That’s very interesting. Would you be willing to share more details as of what you people do? @bediako.george598
Sorry ... just seeing this. We build backend financial and accounting systems for large organizations. We have also built a lightweight spreadsheet engine, compatible with Excel, embeddable in JS, Java, or C# applications. Users can run 100s of these spreadsheets engines simulataneously to acheive scale.
Do you people have a website I can take a look at? To give you some context, I work at Microsoft and I do use some Clojure internally. The idea of a success story of Clojure with the CLR runtime is very appealing and I would love to learn more @bediako.george598
Yes! Have a look at http://www.pebblestream.com and peruse our docs. Also, happy to do a Zoom sometime.
@vincenz.chianese We are using it in production, in the sense that we provide a version of our runtime engine for dotnet use. We expect several of our customers to use the CLR version of the runtime this quarter. Since we are first and foremost a Java shop, we rely on Clojure for the JVM primarily, but every feature we add to our runtime we expect to be supported on JavaScript and C# as well.
The error I'm seeing is "No matching member compare taking 2 args for core$compare__717"
It took me a few minutes to rediscover how Clojure IFns can work as IComparer objects. (Hint: It's not in the IFn definition. It's in AFunction. ) But the real problem is in subseq, not in sorted-map-by or compare. Actually, in what subseq and rsubseq use to create their inclusion tester:
(defn mk-bound-fn
{:private true}
[^clojure.lang.Sorted sc test key]
(fn [e]
(test (.. sc comparator (compare (. sc entryKey e) key)) 0)))
I haven't had time to test it yet, but I'm pretty sure that compare in the last line should be Compare. JVM/CLR library difference.
Thanks for pointing this out. The beta coming out soon (hopefully this week) will have the fix.the only tests for subseq and rsubseq in the core test suite only test against (sorted-set), creating a PersistentTreeSet that is based on a PersistentTreeMap that uses a DefaultComparer. I had defined the latter with both Compare and compare methods, so it doesn't cause a problem. But an arbitrary IFn/`AFunction` implements only IComparer.Compare.
The workaround your developer came up with is neat.
That was @mark.mendell...
I remember touching base with @mark.mendell on here about (checking ...) a year ago.