Remembered an old idea of mine.
I believe names are complected in programming. I’ve talked about this on the mailing list before. Names are used for computer reference, and for us to understand what the function does at a glance. These two use case often interfere with one another.
My idea to decomplect this is for the computer references to be computer generated, and the name to become a doc-name that accompanies the doc-string.
The way I thought Clojure could be extended is that defn would take a reference-id and a doc-name like so:
(defn 989382-a638d827-273u28827
multiply
"Multiplies a with b"
[a b]
(* a b))
If you wanted to use this function, you’d have to call it with its reference-id:
(989382-a638d827-273u28827 10 20)
For convenience, tooling would magically replace all reference-id by the doc-name. So in your idea you could do:
(multiply 10 20)
But the file content would actually have the reference-id in it.
That way, humans can have a name, you could even internationalize the doc-name, giving humans a name in their preferred language. You would be free to change the name whenever, without breaking any reference, no more need to refactor.
Ideally all Clojure def would support this. Maybe symbols could actually be extended to have a doc-name and a symbol, that might allow this pattern everywhere.
Also, I thought of a way to do it without change to Clojure. Come up with a common file format, something called name-reference-map.edn for example. Put it in the root of your project. Inside, a map from name to reference-id would be stored.
{989382-a638d827-273u28827 multiply}
Tools could all learn to support this. So for example, clj-fmt could automatically replace all name to their reference as it formats based on the file. And then Cider would automatically replace all reference by the name in the buffer.
Reference-id don’t have to be a guid loke that. They just need to never change. So this can be backward compatible. Namespace/reference-id is the real reference. Clojure.core/+ for example can be taken as a reference, but you could change its name
{user/989382-a638d827-273u28827 multiply
clojure.core/+ sum}
So now to humans with such a name-reference-map they’d see + as sum everywhere, and coukd call it with sum, but in the source file it would always be +. The code you see is a human projection. This style could allow a hybrid approach, where the first good enough name is the source reference, which would work for tools who don’t yet support the name-reference-map, but by convention you would never change a name after you committed it, instead you’d refactor with the name-reference-map.