clr

Bediako George 2024-09-03T21:01:27.024859Z

@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")

vncz 2024-09-06T21:34:19.561479Z

@bediako.george598 out of curiosity, are you using Clojure with CLR in production, or are you just playing around?

vncz 2024-09-08T14:19:50.911869Z

That’s very interesting. Would you be willing to share more details as of what you people do? @bediako.george598

vncz 2024-09-10T15:42:10.315409Z

@bediako.george598 ?

Bediako George 2024-09-10T15:45:50.168549Z

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.

vncz 2024-09-10T16:43:07.896729Z

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

Bediako George 2024-09-11T03:34:42.103819Z

Yes! Have a look at http://www.pebblestream.com and peruse our docs. Also, happy to do a Zoom sometime.

Bediako George 2024-09-07T13:38:09.315469Z

@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.

dmiller 2024-09-03T21:37:44.575429Z

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.

🖖🏿 1
dmiller 2024-09-04T00:08:28.742189Z

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.

Bediako George 2024-09-04T00:12:01.002109Z

That was @mark.mendell...

dmiller 2024-09-04T00:19:24.530099Z

I remember touching base with @mark.mendell on here about (checking ...) a year ago.