emacs-devel
[Top][All Lists]
Advanced

[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: Thu, 7 May 2020 14:48:34 +0100

On Thu, May 7, 2020 at 2:02 PM Tom Tromey <address@hidden> wrote:
>
> >>>>> "Stefan" == Stefan Monnier <address@hidden> writes:
>
> >> I like the idea of doing it in the reader (it has some nice advantages),
> >> but the downside is it is then harder to special-case defining forms.
>
> Stefan> The upside is that you don't need to recognize defining forms ;-)
>
> Haha, yeah, I suppose so.
>
> The advantages I was thinking of are that it means that it's basically
> impossible to forget a case (like I did with vectors), and that it means
> the local "short" form of the symbol doesn't need to be interned.

Exactly. And that answers my question from before: it seems your current
approach _does_ intern both the short and long form (not a terribly bad
thing, mind you).

So Tom if we combine your "shorthand" approach with a reader-based one
we get a straightfoward, hopefully useful, system.  We could have this
directive in some files:

;;; Shorthand: (("vl-" . "very-long-prefix-")
;;;             ("yalp-" . "yet-another-long-prefix-"))

which would influence the reader.  That way we could have our
very-long-prefix.el library do this:

;; this defines very-long-prefix-foo which calls
;; yet-another-long-prefix-bar.  vl-foo and yalp-bar
;; are never interned.
(defun vl-foo () (substring (yalp-bar) 42 84))

What if later on someone adds an actual symbol vl-foo to the Emacs main
namespace?  Well, I wouldn't be able to see it in my file, but maybe I
don't need to.  If I do need to see it I use some special syntax to tell
the reader to escape the ;; Shorthand: directive, like #vl-foo, which
does mean the symbol named "vl-foo".

What about the printer?  We could decide either way.  I wouldn't
mind seeing my automatically PRINTed code in the long form, but
we could have it be influenced by the shorthand alist and do a
rassoc there.

João



reply via email to

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