Is it possible for Clojure to add an "obj#method" or “obj.method” syntactic sugar?

Is it possible for Clojure to add an “obj#method” or “obj.method” syntactic sugar?

If you add the syntactic sugar of “obj#method” like “class/staticMethod”, it will make the auto-complete better implementation.

“#” has analytical semantics, generally does not appear in the middle of the symbol, it is better on compatibility.

Currently, in notepad++, It can only use “obj.method” to implement retrieval and auto-completion, and then cut “obj” to the back of “.method”.


I believe Cursive has auto-completion on object methods – I think if you type (obj .met... then it offers suggestions based on the type of obj and when the method is selected, it rewrites the expression to (.method obj …

So any editor can provide a syntax for this sort of context-dependent code-assist if it wants to. There’s no need for Clojure itself to make any changes.


Interesting, I just tried that and can confirm that Cursive does rewrite it after autocompletion.

This is also valid syntax:

(let [name "Shaun"]
  (. name toUpperCase))
=> "SHAUN"

I haven’t seen it used much, but it gives you the order you’d want for autocompletion.

(macroexpand '(.toUpperCase "shaun"))
=> (. "shaun" toUpperCase)
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.