Why do clojure libraries reuse commonly occurring function names forcing you to namespace qualify them? For instance clojure.zip uses next, replace and remove which already exist in clojure core and "replace" already exists in clojure.string.
Now the developer will probably use some abbreviation for the clojure.zip namespace so in one developer's code the clojure.zip/next will be namespace qualified as z/next in another person' s code as w/next, etc. This will force you to look back to see what the name space abbreviation actually is because the developer could have created his own library which also uses the function "next"
Why not zip-next, zip-replace , and zip-remove, str-replace? Or something like that
Then there will be a consistent "namespace qualification" in people's code and it will be clear what these functions refer to.
It's not like there are hundrends of names clashes between libraries. I typically see only two or three . Is it so hard to explictly make these names unique to the library?
In general using use
to include libraries is less popular than using require
in normal looking clojure code, so using longer unique names is less useful when the namespace already conveys the same meaning so clojure programmers tend to prefer brevity to uniqueness.
instead of:
(use 'liba 'libb)
(liba-foo 1 2 3)
(libb-foo 1 2 2)
people could then write:
(require ['liba :as 'a] [libb :as 'b] )
(a/liba-foo 1 2 3)
(b/libb-foo 1 2 3)
which makes the liba- seem silly, hence:
(a/foo 1 2 3)
(b/foo 1 2 3)
If you're going to require that names be globally unique, why have namespaces at all? If I define the icecream library, and prefix every function name with icecream, nobody can ever conflict.
But this is terribly inconvenient for both parties - we all have to keep typing this stupid prefix over and over. If instead of icecream-scoop, I just name my function scoop inside the namespace icecream, you have choices of how to refer to it: you can call it scoop if it's clear from context and doesn't clash with your namespace, or icecream/scoop, or dessert/scoop, whatever you need to make it read well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With