From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: new `obarray` type
Date: Tue, 14 Mar 2017 20:14:14 +0000 [thread overview]
Message-ID: <20170314201414.GA4562@acm> (raw)
In-Reply-To: <jwv60jcqcv2.fsf-monnier+Inbox@gnu.org>
Hello, Stefan.
On Tue, Mar 14, 2017 at 08:52:59 -0400, Stefan Monnier wrote:
> > It's not more palatable to this user. It sounds more like "dumbing
> > down". There are few things more frustrating whilst debugging than
> > having Emacs obfuscating information "for my own good".
> The good thing about having the `obarray` type is that e get to choose
> how to print them.
> I can easily make it so it prints all the symbols in it, would you
> prefer that?
Yes, please!
> > Indeed, why not just print _all_ vectors by printing only their size?
> The reason why the patch I sent only prints the number of entries is
> that currently the way obarrays are printed you only get to see some of
> the symbols but not all. But I guess you're right: it would be more
> useful to list all the symbols in it.
> [ Time passes... Done! ]
Apologies for that. I wasn't really aware that (currently) printing an
obarray only displays some of the symbols.
> > Not rarely, particularly in CC Mode, I will be dealing with obarrays
> > with relatively small numbers of symbols.
> Regardless of what we decide to do with obarrays, I strongly recommend
> you change cc-mode to use hash-tables instead. My experience with EIEIO
> (where I "recently" moved from obarrays to hash-tables) is that it's
> measurably faster and the code tends to be clearer (tho that's clearly
> subjective).
There are currently four uses of (make-vector LENGTH 0) in CC Mode, at
least one of which, possibly two, genuinely deal with Lisp symbols.
Converting those to hash-tables would probably be a net loss, though
converting the ones which just use obarrays as a string look-up would
surely gain.
> > Of course I want to see these symbols' names when I ask for that
> > obarray to be printed.
> With hash-tables, you'll them see all, properly printed and even `read`able!
> > I'm also not in favour of introducing another vector-like type without a
> > very good reason.
> Obarrays are very weird, currently, because they combine "plain vectors"
> and "plain symbols" in a tricky way.
> - Have you ever tried to do `aref` on an obarray?
> - The printout lists some of the symbols, but not all. Which ones appear
> is arbitrary, unpredictable.
> - Have you ever tried to put something else than 0 in an obarray slot?
> - An obarray can lead to unexpected space behavior:
> (let* ((o (obarray-make))
> (s1 (intern "s1" o))
> (s2 (intern "s2" o)))
> (set s1 (make-list 100000 t))
> s2)
> might leave you with a 10000-element list preserved as "reachable" as
> long as `s2` is reachable, even tho it's clearly not reachable any more.
> BTW, my patch doesn't address this GC problem yet.
> > positions. Would a new obarray type prevent any vector operations being
> > carried out on it, should any package do such things? If so, that would
> > be a Bad Thing.
> Currently, I haven't changed `aref` to work on obarrays, no. I've never
> ever seen code try to do that (I guess in theory it could be potentially
> useful, tho I can't think of any operation you could implement reliably
> using `aref` on obarrays would be `obarray-empty-p`).
> I was planning on allowing `aset` in case some package uses it to do the
> equivalent of `clrhash`, but I haven't yet found any package doing that,
> so I haven't bothered either.
> > This change would create hassle in general for many packages, all of
> > which create obarrays with (make-vector LENGTH 0), and would need
> > changing to use `make-obarray'.
> Of course, (make-vector LENGTH 0) still works. And there's
> obarray-make, introduced in Emacs-25, IIRC. But even if we deprecate
> (make-vector LENGTH 0) you won't get any byte-compilation warning for it
> since we can't detect whether a (make-vector LENGTH 0) is meant as an
> obarray or as a normal array that happens to be filled with zeroes.
You could prohibit symbol operations on the "wrong" type of vector.
> > It would mean having to write yet more compatibility macros (for the
> > inevitable day when old style obarrays get removed from Emacs).
> To the extent that we can't detect when make-vector is used for an
> obarray, I expect that it'll take *many* years until we can drop support
> for "old-style" obarrays, so I wouldn't worry about it.
> I suspect that even cc-mode will have switch to hash-tables before
> support for old-style obarrays is dropped.
Hee!
Thanks for this reply. I withdraw my objections to the new obarray
type.
> Stefan
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2017-03-14 20:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-13 1:36 new `obarray` type Stefan Monnier
2017-03-13 15:49 ` Eli Zaretskii
2017-03-13 17:22 ` Stefan Monnier
2017-03-13 22:03 ` Alan Mackenzie
2017-03-14 1:46 ` Herring, Davis
2017-03-14 12:52 ` Stefan Monnier
2017-03-14 20:14 ` Alan Mackenzie [this message]
2017-03-15 17:25 ` Stefan Monnier
2017-03-15 18:19 ` Lars Brinkhoff
2017-03-15 19:24 ` (:named nil) in cl-defstruct (was: new `obarray` type) Stefan Monnier
2017-03-15 19:39 ` Noam Postavsky
2017-03-15 20:28 ` (:named nil) in cl-defstruct Stefan Monnier
2017-07-23 14:03 ` Converting CC Mode's obarrays to hash tables. [Was: new `obarray` type] Alan Mackenzie
2017-07-24 14:06 ` 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=20170314201414.GA4562@acm \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.