emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proper namespaces in Elisp


From: Daniel Colascione
Subject: Re: Proper namespaces in Elisp
Date: Fri, 8 May 2020 12:34:49 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/8/20 11:59 AM, Vladimir Sedach wrote:

Daniel Colascione <address@hidden> writes:
Common Lisp does deal with this problem in some cases, e.g., in LOOP.
We should be moving forwards keywords anyway.

LOOP would not even have to deal with that if namespaces were over
bindings, like Andrea suggested, and what Scheme module systems do.

FWIW, I think elisp should just literally copy Common Lisp's
approach.

Please see this other sub-thread where I explain why this is a really
bad idea:

https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg00623.html

It's tried and tested, and the pitfalls are well-understood.

Well-understood enough where people want to throw away most of how it
does namespace imports, and have a backward-compatible replacement
ready this year:

https://gist.github.com/phoe/2b63f33a2a4727a437403eceb7a6b4a3

I wouldn't call package-local nicknames "throw[ing] away" the namespace system. The post describes a logical extension. Is your argument that the CL namespace system (suitably extended) *allows* people to do silly things (like :use) even though it doesn't require that they do?

There is no need to repeat the same mistakes. Andrea's proposal for
namespacing over bindings/Scheme's approach avoids mangling the
reader, does not cause problems for the printer, and does not make
code resort to symbol-name hacks like LOOP does. Scheme's approach to
namespacing has a lot of advantages over Common Lisp's.

We can also avoid the "namespace multiple inheritance" problems of
unintended re-definition and import conflicts if we combine João's
approach of declaring prefixes with the ideas of package-local
nicknames and namespaces over bindings.

Here is how that might look:

--8<---------------cut here---------------start------------->8---
(declare-namespace jennys-awesome-string-library
   (use elisp29)
   (export foo))

(declare-namespace jonnys-amazing-syntax-library
   (use elisp29)
   (export foo))

(declare-namespace some-new-library
   (use elisp30)
   (import jennys-awesome-string-library st-)
   (import jonnys-amazing-syntax-library sy-))

Fair enough. What about requiring that a colon separate the module prefix from the remainder of the symbol? Using a dash seems ripe for misinterpretation, but someone reading a symbol containing colon (in a way that looks vaguely reminiscent of CL) would know to look for a namespace alias instead of searching in vain for some global definition of st-foo or sy-foo.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]