Fork me on GitHub
#clojure-dev
<
2024-07-15
>
Noah Bogart15:07:57

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)16:07:43

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

Noah Bogart17:07:59

that's great to hear

Noah Bogart17:07:18

hell yeah, thanks.

Noah Bogart17:07:55

no jira for "find-first" lmao

Alex Miller (Clojure team)17:07:38

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

👍 1
Alex Miller (Clojure team)17:07:02

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

Noah Bogart17:07:47

oops, missed that.

Noah Bogart18:07:54

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?

Alex Miller (Clojure team)18:07:50

Invoke-static is for direct linking

Noah Bogart18:07:23

when is invoke not a direct call into invokeStatic?

Alex Miller (Clojure team)18:07:28

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

Alex Miller (Clojure team)18:07:07

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

Alex Miller (Clojure team)18:07:33

Let me know if that did not resolve your question

Noah Bogart18:07:00

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

Noah Bogart18:07:59

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)18:07:19

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

Alex Miller (Clojure team)18:07:44

I think invoke is also used in hof call regardless?

Alex Miller (Clojure team)18:07:10

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)18:07:57

You can’t always make the static call

hiredman18:07:02

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

hiredman18:07:19

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

Noah Bogart14:07:49

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

Noah Bogart14:07:34

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

Alex Miller (Clojure team)15:07:24

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)15:07:18

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

👍 1
Noah Bogart15:07:28

cool, thanks for the explanations