clojure 2026-11-13

you can use .foo or .-foo to access member variables via interop. However, com.bar.Foo/.foo and com.bar.Foo/.-foo only works for methods. Is there a reason for that? I like the fully qualified version since it let’s me use autocomplete to find member variables.

Alex Miller (Clojure team) 2026-11-13T20:44:34.293269Z

.foo works for either methods or fields (any member, resolves to method if both) .-foo is only fields com.bar.Foo/.foo is a qualified method - the goal here was to make higher order invokable thing, fields are not invokable com.bar.Foo/.-foo is not valid syntax

I realize that’s how it works. Is there a reason why com.bar.Foo/.-foo shouldn’t be valid syntax?

➕ 1

basically, is it worth making an ask.clojure question?

One of the main reasons I have really liked method values is that it works well with autocomplete

Method values also work well with clojure.java.doc.api for pulling up javadocs in my editor

Alex Miller (Clojure team) 2026-11-13T20:54:24.357499Z

I said the reason - qualified methods are higher order invokable functions, qualified fields are not invokable things

Alex Miller (Clojure team) 2026-11-13T20:54:55.164389Z

that is, this was intentional

👍 1

ok. I was confused because you said fields are not invokable rather than fields should not be invokable. It seems plausible that fields could (or maybe should) be invokable just like keywords.

Alex Miller (Clojure team) 2026-11-13T21:12:03.969089Z

fields are values

Alex Miller (Clojure team) 2026-11-13T21:12:21.822589Z

the field value itself MIGHT be invokable, although that’s probably a rare case

you need to supply an object for an instance field to be a value, right?

I guess the overloading between static and instance fields makes this complicated

Alex Miller (Clojure team) 2026-11-13T21:13:46.738199Z

if that was a thing, yes. but it’s not a thing