[Top][All Lists]

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

Re: Proper namespaces in Elisp

From: Vladimir Sedach
Subject: Re: Proper namespaces in Elisp
Date: Fri, 08 May 2020 11:59:28 -0700
User-agent: mu4e 1.3.10; emacs 26.2

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:


> 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:


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-))
--8<---------------cut here---------------end--------------->8---

In some-new-library, st-foo refers unambiguously to the binding of
foo in jennys-awesome-string-library, and sy-foo to the binding of
foo in jonnys-amazing-syntax-library. If a package wants a literal
quoted symbol like 'string as input somewhere, or as a literal in a
macro (LOOP), that is no problem (it would be in Common Lisp!).

No modifications to the reader or printer needed.

You can even specify the prefix to end in a semicolon, and it looks
like Common Lisp. I think a visually distinct separator like a
semicolon has a lot of legibility advantages, and this scheme lets
you choose whatever you prefer.

Vladimir Sedach
Software engineering services in Los Angeles https://oneofus.la

reply via email to

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