unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Vladimir Sedach <vas@oneofus.la>
To: Daniel Colascione <dancol@dancol.org>
Cc: "João Távora" <joaotavora@gmail.com>,
	"Tom Tromey" <tom@tromey.com>,
	"Stefan Monnier" <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: Re: Proper namespaces in Elisp
Date: Sat, 09 May 2020 18:19:40 -0700	[thread overview]
Message-ID: <87tv0o1t8z.fsf@t510.orion.oneofus.la> (raw)
In-Reply-To: <E1jXDPd-0000nm-T2@dancol.org>


Daniel Colascione <dancol@dancol.org> writes:
> So there are three basic operations we can support: in Python syntax,
> 1) from PKG import * (exposing PKG.foo as foo), 2) import PKG as p
> (exposing PKG.foo as p.foo) and 3), from PKG import foo (exposing
> PKG.foo as foo).  CL supports all three. I'm most interested in
> supporting #2, since that's closest to existing use. The lexspace
> prototype posted earlier today supports #3 and #1 (the latter via
> lexspace inheritance) only, but I think we should do #2 instead, and
> I think we can do it without runtime overhead.

Before I write anything else, I have to call attention to a fact you
might already be aware of: Python cannot do code re-loading reliably,
because depending on which of these 3 ways a function is imported,
the new definition might or might not be seen.

This is a really good example of the way that namespace systems can
have unintended consequences, and why we have to be careful designing
one for Elisp.

#3 is ok, because that way you know exactly what you are importing,
and will not get any surprises if PKG exports another definition
later.

Most use cases want a single #1 to pull in the language that you are
working in (in Common Lisp, this would be the "COMMON-LISP" package).

As I pointed out in another sub-thread, this can be used to advantage
if you version Elisp namespaces to major Emacs versions (elisp29,
elisp30, etc.). It is a lot easier to support backwards compatibility
and make major changes to Emacs that way.

The only problem is retrofitting this on top of the global namespace.
The global namespace is going to have to be a fallback for all symbol
lookups. Existing libraries also need to have their declared exports
put into the global namespace with their chosen package prefix and
appropriate autoloads, to be compatible with packages that do not use
namespaces (advice/redefinition is going to have to do the
appropriate thing in both places, and dynamic bindings have to be
shared!). Modifying internal functions is already a gamble on
updates, so I think it is ok to tell people "you need to access this
internal function with a namespace qualifier because the package now
uses namespaces."

The reason #1 becomes a problem is if you do it two or more times.
This is akin to "namespace multiple inheritance." This is different
from multiple inheritance in OO because it is not transitive (you do
not want to import the dependencies of the package you are
importing!).

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



  parent reply	other threads:[~2020-05-10  1:19 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 10:52 Proper namespaces in Elisp João Távora
2020-05-04 15:11 ` Adam Porter
2020-05-04 15:38   ` Clément Pit-Claudel
2020-05-04 15:49     ` João Távora
2020-05-04 16:39       ` Adam Porter
2020-05-04 16:49         ` João Távora
2020-05-04 18:00       ` Clément Pit-Claudel
2020-05-04 20:19       ` Vladimir Sedach
2020-05-05  2:51     ` Richard Stallman
2020-05-04 15:29 ` Clément Pit-Claudel
2020-05-04 16:04   ` João Távora
2020-05-04 18:29     ` Helmut Eller
2020-05-04 18:39     ` Stefan Monnier
2020-05-04 19:02       ` João Távora
2020-05-04 19:20         ` Stefan Monnier
2020-05-04 19:49           ` João Távora
2020-05-04 21:59         ` Andrea Corallo
2020-05-04 22:34           ` João Távora
2020-05-05 10:33             ` Andrea Corallo
2020-05-05 10:54               ` Andrea Corallo
2020-05-05 12:50               ` João Távora
2020-05-05 13:34                 ` Andrea Corallo
2020-05-05 14:03                   ` João Távora
2020-05-05 14:26                     ` Andrea Corallo
2020-05-05 21:20                       ` João Távora
2020-05-05 23:37                         ` Andrea Corallo
2020-05-06  0:15                           ` João Távora
2020-05-06  7:07                             ` Andrea Corallo
2020-05-06 19:48                               ` João Távora
2020-05-07  6:13                                 ` Andrea Corallo
2020-05-05 13:45               ` Stefan Monnier
2020-05-05 14:07                 ` João Távora
2020-05-05  4:55           ` Helmut Eller
2020-05-04 21:40     ` Vladimir Sedach
2020-05-04 22:09       ` João Távora
2020-05-05  1:09         ` Vladimir Sedach
2020-05-05  9:38           ` João Távora
2020-05-05 16:41             ` Vladimir Sedach
2020-05-05 21:29               ` João Távora
2020-05-06  3:25                 ` Vladimir Sedach
2020-05-06 19:38                   ` João Távora
2020-05-06 22:47                     ` Vladimir Sedach
2020-05-07 10:00                       ` João Távora
2020-05-07 18:30                         ` Vladimir Sedach
2020-05-07 19:32                           ` João Távora
2020-05-04 22:40       ` João Távora
2020-05-05  1:24         ` Vladimir Sedach
2020-05-04 15:43 ` Stefan Monnier
2020-05-05 15:10 ` Tom Tromey
2020-05-05 21:30   ` João Távora
2020-05-07  2:23     ` Tom Tromey
2020-05-07  3:12       ` Stefan Monnier
2020-05-07 13:02         ` Tom Tromey
2020-05-07 13:48           ` João Távora
2020-05-07 18:17             ` Stefan Monnier
2020-05-07 18:48               ` Vladimir Sedach
2020-05-07 20:33                 ` João Távora
2020-05-08  2:56                   ` Vladimir Sedach
2020-05-08 15:56                     ` João Távora
2020-05-08 17:59                       ` Vladimir Sedach
2020-05-08 18:38                         ` João Távora
2020-05-07 19:37         ` Daniel Colascione
2020-05-07 20:28           ` Stefan Monnier
2020-05-07 20:42             ` Daniel Colascione
2020-05-07 21:06               ` Stefan Monnier
2020-05-07 21:10                 ` Daniel Colascione
2020-05-07 21:46                   ` João Távora
2020-05-07 21:56                     ` Daniel Colascione
2020-05-07 22:12                       ` João Távora
2020-05-08 18:59               ` Vladimir Sedach
2020-05-08 19:34                 ` Daniel Colascione
2020-05-09  0:00                   ` Vladimir Sedach
2020-05-09  0:32                     ` Daniel Colascione
2020-05-09  8:37                       ` Andrea Corallo
2020-05-09 16:11                         ` Daniel Colascione
2020-05-09 17:25                           ` Andrea Corallo
2020-05-09 17:45                             ` Daniel Colascione
2020-05-09 18:23                               ` João Távora
2020-05-09 18:32                                 ` Daniel Colascione
2020-05-09 18:35                                   ` João Távora
2020-05-09 18:39                                     ` Daniel Colascione
2020-05-09 19:11                                       ` João Távora
2020-05-09 18:30                               ` Andrea Corallo
2020-05-09 18:33                                 ` Daniel Colascione
2020-05-09 18:48                                   ` Andrea Corallo
2020-05-09 20:34                                     ` Why :USE sucks in the Common Lisp package system Michał "phoe" Herda
2020-05-09 21:47                                       ` João Távora
2020-05-09 21:55                                         ` Michał "phoe" Herda
2020-05-09 22:01                                           ` Daniel Colascione
2020-05-09 22:07                                             ` Michał "phoe" Herda
2020-05-09 22:12                                           ` João Távora
2020-05-10 10:10                                             ` Michał "phoe" Herda
2020-05-09 23:23                                       ` Andrea Corallo
2020-05-10  6:46                                         ` Andreas Schwab
2020-05-10  8:53                                           ` Helmut Eller
2020-05-10  9:59                                             ` Michał "phoe" Herda
2020-05-10  1:19                       ` Vladimir Sedach [this message]
2020-05-08 23:07                 ` Proper namespaces in Elisp Andrea Corallo
2020-05-08 23:23                   ` Stefan Monnier
2020-05-09  8:12                     ` Andrea Corallo
2020-05-09 12:06             ` Tuấn-Anh Nguyễn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tv0o1t8z.fsf@t510.orion.oneofus.la \
    --to=vas@oneofus.la \
    --cc=dancol@dancol.org \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).