all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Richard Stallman <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: lexicons
Date: Tue, 30 Jul 2013 23:47:58 -0400	[thread overview]
Message-ID: <jwvk3k7tnuy.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1V4HtQ-0004dT-Gy@fencepost.gnu.org> (Richard Stallman's message of "Tue, 30 Jul 2013 17:55:44 -0400")

> I read the documentation of lexicons, and they seem to solve the
> problems that made me dislike CL packages.

I also prefer the semantics of lexicon over that of CL packages.
But I don't think this would fly for Elisp, because it completely
separates the notion of symbol from the notion of its binding, so things
like (symbol-value 'foo) don't behave like `foo' any more, so it's
a pretty drastic change.

I think what you don't like is this idea of "look around in various
obarrays to find the symbol that is meant".  I tend to agree here: doing
it at compile/run-time (as in the case of lexicons) might be acceptable
(because you can then distinguish definitions from uses), but doing it
at read-time is more problematic, especially when one of the obarrays is
the global one which can hold any kind of random crap thanks to the
myriad of poorly written packages, or because of code copy&pasted from
the web into the user's ~/.emacs.

While some people think that even a 3-letter prefix is completely
unacceptable (I'll let you guess which prefix I'm thinking about),
I tend to think that using prefixes is not that bad, as long as they're
kept short.

But I agree that there's a problem here: we want prefixes in the code to
be short, but namespace cleanliness wants us to use longish prefixes.

So maybe the solution is simply to provide prefix shorthands.
Chose a "prefix char" (there's a good time for bikeshedding here), let's
say | for now.  Then you could define (file-locally):

   prefixes-alist: '(("" "mypackage-") ("gs" "gnus-summary-"))

and then use `|foo' as a shorthand for `mypackage-foo' and `gs|bar' as
a shorthand for `gnus-summary-bar'.

It's still a read-time operation (which means that it will work just
fine with people's bad habits of using ' to quote code and things like
that), but it doesn't suffer from the ambiguity of a search through
various obarrays.

This wouldn't let you "import without a prefix", but it would free
people to use longish prefixes, since you can locally shorten the ones
you care about (a common practice in the SML module system, where you
typically import modules while renaming them to a very short (1 or
2 chars) local name).


        Stefan



  reply	other threads:[~2013-07-31  3:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-30 21:55 lexicons Richard Stallman
2013-07-31  3:47 ` Stefan Monnier [this message]
2013-07-31 10:27   ` lexicons Lars Magne Ingebrigtsen
2013-08-01 21:46     ` lexicons Stefan Monnier
2013-08-01 21:57       ` lexicons Lars Magne Ingebrigtsen
2013-08-02  4:53         ` lexicons Teemu Likonen
2013-08-02  5:00         ` lexicons Lars Brinkhoff
2013-08-02 12:25           ` lexicons Lars Magne Ingebrigtsen
2013-08-02  6:41         ` lexicons Bastien
2013-08-02 13:50           ` lexicons Stefan Monnier

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=jwvk3k7tnuy.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /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.