all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Vladimir Sedach <vas@oneofus.la>
To: "João Távora" <joaotavora@gmail.com>
Cc: nic@ferrier.me.uk, "Clément Pit-Claudel" <cpitclaudel@gmail.com>,
	emacs-devel@gnu.org
Subject: Re: Proper namespaces in Elisp
Date: Mon, 04 May 2020 14:40:15 -0700	[thread overview]
Message-ID: <87v9lb1irk.fsf@t510.orion.oneofus.la> (raw)
In-Reply-To: <CALDnm50PwYy0HXN7WfWZyO109AcrARH0s6bkv-g-Fz-qsmSqhg@mail.gmail.com>


João Távora <joaotavora@gmail.com> writes:
> I would also prefer CL packages but if a lower
> effort thing can solve _some_ problems, and be backward compatible
> and not slow down compilation, maybe we should give it a shot.

The one big problem with the Common Lisp package system that should
not be copied over is the package :use mechanism:

--8<---------------cut here---------------start------------->8---
CL-USER> (defpackage "ABC" (:use "CL") (:export "FUNC1"))
#<PACKAGE "ABC">
CL-USER> (defun abc:func1 (x y) (list x y))
ABC:FUNC1
CL-USER> (abc:func1 1 2)
(1 2)
CL-USER> (defpackage "XYZ" (:use "CL" "ABC"))
#<PACKAGE "XYZ">
CL-USER> (defun xyz::func1 (x y) (+ x y))
WARNING: redefining ABC:FUNC1 in DEFUN
ABC:FUNC1
CL-USER> (abc:func1 1 2)
3
--8<---------------cut here---------------end--------------->8---

This causes problems when a new version of a library introduces a new
function FUNC1, which definition gets unknowingly overridden for
everybody by another package that uses the library. Explicitly using
:import avoids this problem, and makes figuring out who-uses-what
easier.

There has been lots of talk about the reader here, but no one has
brought up the printer. Any namespace system is going to have to
print symbols in a way such that they can be read back in EQually.

Common Lisp does not do a good job of this, because whether or not a
symbol's package prefix is printed depends on the current package you
are in when printing.

Any namespace system is going to have to be first-class itself, with
first-class identifiers (otherwise see Python, where code cannot be
re-loaded correctly depending on how import was done), which implies
full introspection support. Any system that makes it a chore to
re-define functions outside of the files they were defined in should
be rejected.

Namespaces are helpful for organizing code in a project, but they are
not going to stop people from naming their packages with one or two
or three letter names (happens with Common Lisp libraries all the
time), or stop people from naming their packages in a way that
conflicts with older libraries they were not aware of (also happens).
Those two arguments are not valid ones for introducing a namespace
system.

> Anyway, are there any contemporary objections to Nic's plan

I think a namespace system could be useful for:

1. Keeping people from accidentally defining and dynamically binding
   symbols they did not mean to in their packages.

2. Describing autoloads in a convenient first-class way. "Magic
   comments" and decorators are a terrible hack for defective
   languages; there is never a real need for them in Lisp. Same
   reason why any proposal that suggests declaring namespaces in
   comments should be rejected (my major objection to Nic's
   proposal).

3. Make it easier for people to see what commands/functions/variables
   a package provides, because they are all declared to be exported
   in a single place, and can also be queried from code because the
   namespace system is first-class and introspective.

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



  parent reply	other threads:[~2020-05-04 21:40 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 [this message]
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                       ` Proper namespaces in Elisp Vladimir Sedach
2020-05-08 23:07                 ` 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

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

  git send-email \
    --in-reply-to=87v9lb1irk.fsf@t510.orion.oneofus.la \
    --to=vas@oneofus.la \
    --cc=cpitclaudel@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=nic@ferrier.me.uk \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.