News for hackers. Stuff that matters.
Re:Try Clojure by ilikehurdles on Thursday May 23, 2024 @02:02AM (#40451005)
No. When working with JVM/typescript libraries you have their autocomplete information.

If you need method autocomplete scoped to a type you can use the `..` macro for more concise call syntax:

    (ns my-project.core
      (:import (java.util ArrayList Collections)))

    (defn example []
      (let [list (ArrayList.)]    ; ArrayList constructor can be autocompleted
        (.. list
            (add "Hello")         ; The .add method on ArrayLists will be autocompleted
            (add "World")
            (add "Clojure"))
        (Collections/sort list)   ; The Collections.sort method will be autocompleted
        list))

this other form will a also autocomplete everything after the dot (.) to call a method on an object:

    (.toUpperCase some-str)
but the trick with this arrangement is to write that variable some-str first, then if you write . in front of it the autocompletes will be relevant to that object. But I gratuitously used threading macros like .. or -> to make it match java-style code (in other words: (-> some-str (.toUpperCase))).
Re:Try Clojure by createaccount99 on Thursday May 23, 2024 @02:22AM (#40451133)
That's cool, I had no idea. In clojure itself I suppose you eval code and then get autocompeletes from the repl output? -- I mean for stuff with no types
Re:Try Clojure by simongray on Thursday May 23, 2024 @02:51AM (#40451330)
Autocomplete also works for the functions and vars in the namespaces. You don't really use methods in Clojure unless you're doing interop with Java or JS.