clojure-dev 2024-07-15

is it possible to remove locked Asks from the "Highest Votes" page? I can do it mentally myself, but it would be nice to have it automated too. https://ask.clojure.org/index.php/questions/clojure?sort=votes

Alex Miller (Clojure team) 2024-07-15T16:26:43.247259Z

We actually have a thing to make a sheet for better review, and could make the output public somewhere

that's great to hear

no jira for "find-first" lmao

Alex Miller (Clojure team) 2024-07-15T17:53:38.319869Z

see the READ ME tab, jira stuff is scraped, may be incomplete

πŸ‘ 1
Alex Miller (Clojure team) 2024-07-15T17:54:02.039559Z

there was a jira for that, and it was already declined, but I have left it open to ask Rich again

what is the purpose of both invoke and invokeStatic for compiled classes of functions? Why can't there just be a single invoke that does the thing?

the static call is nice because it doesn't require creating an instance of the function? aka you don't have to write Object foo = new example.core$foo(); return foo.invoke(), you can just write return example.core$foo.invokeStatic(); or something

i guess the complexity of juggling static invocations vs instance invocations is worthwhile for performance?

Alex Miller (Clojure team) 2024-07-16T15:01:24.346589Z

when you can make the static call (and avoid the synchronization point of the var lookup), it is a substantial win

πŸ‘ 1
Alex Miller (Clojure team) 2024-07-16T15:02:18.479769Z

in general, static calls are ideal for inlining (both from external use or invoke -> invokeStatic)

πŸ‘ 1

cool, thanks for the explanations

Alex Miller (Clojure team) 2024-07-15T18:27:50.476289Z

Invoke-static is for direct linking

when is invoke not a direct call into invokeStatic?

Alex Miller (Clojure team) 2024-07-15T18:28:28.303029Z

Call sites with dl make a direct static method invocation without going through the var

Alex Miller (Clojure team) 2024-07-15T18:29:07.836989Z

Var calls look up the var, get the function object and invoke

Alex Miller (Clojure team) 2024-07-15T18:30:33.311009Z

Let me know if that did not resolve your question

i'm speaking mostly from ignorance because i don't know jvm asm and don't quite know how the compiler works, i only have looked at the clj-decompiler output and read stack traces, but it seems to me that whatever is passed to invoke is going to be passed to invokeStatic, so in both cases, they're doing the same thing

when i write (foo 100), there's a var lookup (to handle bindings, etc) of foo. but that's still a call to (Var.lookup(new Symbol(null, "foo"))).invoke(100) or something, right? why not just generate (Var.lookup(new Symbol(null, "foo")).invokeStatic(100)?

Alex Miller (Clojure team) 2024-07-15T18:48:19.892999Z

The invoke has existed since the beginning so one answer is backwards compatibility

Alex Miller (Clojure team) 2024-07-15T18:49:44.142519Z

I think invoke is also used in hof call regardless?

Alex Miller (Clojure team) 2024-07-15T18:51:10.992919Z

In hof you are passing an instance with possibly closed over Val’s and you need to invoke through the object, not statically (statics can use the instance closed over values)

Alex Miller (Clojure team) 2024-07-15T18:51:57.194009Z

You can’t always make the static call

invokeStatic is a java static method, so no instance data (can't close over anything)

so obviously not suitable for the general case of representing invoking functions (which can close over data)