[Top][All Lists]

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

Re: Proper namespaces in Elisp

From: João Távora
Subject: Re: Proper namespaces in Elisp
Date: Tue, 5 May 2020 22:30:26 +0100

On Tue, May 5, 2020 at 4:10 PM Tom Tromey <address@hidden> wrote:
> >>>>> "João" == João Távora <address@hidden> writes:
> João> An here's the idea: if the compiler uses the lexical-binding file-local 
> var
> João> when compiling specific files, or functions inside those files, why 
> can't
> João> it use a local-namespaces var when reading symbols?  I think this
> João> very idea was floated at the time, but I can't find it.
> I did something like this
> https://github.com/tromey/emacs-module
> It lets you write short names for things in your elisp; and lets you
> import names with a shorter form.  However, the underlying symbols
> actually use prefixes, in the traditional elisp way.

So you're saying one just types "s-format", but the actual symbol
that elisp sees is modern-string-format? That's great! Are both
symbols interned?  Only for vars&functions? I could live with that.

It seems similar my "shorthand" idea
but that idea would fall into the pitfall of:

    "the Emacs core sometimes requires certain symbol names in APIs."

unless, that is, you added syntax to escape renaming in _those_
situations, like `::`

> Unlike the "Names" package, it doesn't require wrapping your entire file
> in a macro.

That's good.  With some more tweaking maybe you could even
use a fancy ";;; Directive: " instead of the the `define-module` and
the `import-module`, and have modules automatically defined from
file names and existing Elisp internal/external naming conventions.
This is so that those top-level forms don't remind people too much
of the CL packages they love to hate :-)

>  Instead it works using advice, in particular on
> internal-macroexpand-for-load.

That's good!

> João> thing-at-point would also be taught about these local-namespaces
> João> so xref and C-h f stuff would work  well.  Grep wouldn't know about it,
> João> sure, that's true, but that's something that already afflicts other
> João> languages with namespace qualifiers and isn't a terrible thing.
> João> Any other great difficulties you can think ot?
> These were the main problems I had when using it.

I think I could fix the thing-at-point thing reasonably easily. And, as
I wrote, the grep thing is just what you already get anyway when
you start using namespaces, in any language.

João Távora

reply via email to

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