Q: Why does elisp not have namespaces, and how could we get them?
Elisp does not have namespaces other than the global one, which has led to the coding convention of prefixing all global functions, variables, and constants with a unique prefix.
Aside from the annoyance factor, it also strikes me as a simmering issue given 1) the ever-expanding number of great libraries and packages, and 2) the continued existence of legacy functions and variables that either don't respect the prefix convention, or are sufficiently idiosyncratic that there isn't really a good prefix option they could use. It also means that periodic attempts to rationalize older code (as with the transition from
cl-lib) is a non-trivial amount of work. (Although I'm glad for the clean-up, I still shed a tear every time I type something like
I went poking around to see if I could find out why elisp still doesn't have namespaces after a few decades of use, but was a little surprised at the modest harvest. The wiki page on namespaces is quite short. Nic Ferrier has a slightly longer treatment of the issue, and there's a fairly recent thread on emacs-devel on it as well. There's an old Stack Overflow thread from 2010 that discusses the possibility of using macros to implement namespaces; another example of the macro approach can be found here. There are at least a couple of implementations (here and here, with a description of the latter here) out there, but they haven't seen much activity for a couple of years, and I've not run across any libraries that use them.
I presume that, if adding namespaces were easy, it would already be done. So:
- What are the technical barriers to adding namespaces to elisp?
- Would adding namespaces break a lot of existing code?
- Is this functionality something that needs to be organic to elisp (changes to the interpreter itself), or could it really be built on top via macros?