From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: new `obarray` type Date: Tue, 14 Mar 2017 08:52:59 -0400 Message-ID: References: <20170313220335.GA5098@acm> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489496034 29170 195.159.176.226 (14 Mar 2017 12:53:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Mar 2017 12:53:54 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Mar 14 13:53:50 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cnlxT-0006xk-T3 for ged-emacs-devel@m.gmane.org; Tue, 14 Mar 2017 13:53:47 +0100 Original-Received: from localhost ([::1]:58607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnlxa-00080P-1k for ged-emacs-devel@m.gmane.org; Tue, 14 Mar 2017 08:53:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnlwn-0007a0-G8 for emacs-devel@gnu.org; Tue, 14 Mar 2017 08:53:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnlwk-0004Ex-Cc for emacs-devel@gnu.org; Tue, 14 Mar 2017 08:53:05 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:64872) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnlwk-0004EG-61 for emacs-devel@gnu.org; Tue, 14 Mar 2017 08:53:02 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0D0IgAC58dY/9TkSC1dHAEBBAEBCgEBgycqgRKDa4VXhG6RaZdKhiICgkdDFAECAQEBAQEBAWsohRYBBAFnEgULCw0BJhIUGDGKCwivYyYCijkBAQEHAiaLPYo5BZVrhliUNohIJgyBHIUUk0c2IYEEIxYILEGEVh6BfySJZwEBAQ X-IPAS-Result: A0D0IgAC58dY/9TkSC1dHAEBBAEBCgEBgycqgRKDa4VXhG6RaZdKhiICgkdDFAECAQEBAQEBAWsohRYBBAFnEgULCw0BJhIUGDGKCwivYyYCijkBAQEHAiaLPYo5BZVrhliUNohIJgyBHIUUk0c2IYEEIxYILEGEVh6BfySJZwEBAQ X-IronPort-AV: E=Sophos;i="5.36,163,1486443600"; d="scan'208";a="295249245" Original-Received: from unknown (HELO pastel.home) ([45.72.228.212]) by smtp.teksavvy.com with ESMTP; 14 Mar 2017 08:52:59 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 2B4256219A; Tue, 14 Mar 2017 08:52:59 -0400 (EDT) In-Reply-To: <20170313220335.GA5098@acm> (Alan Mackenzie's message of "Mon, 13 Mar 2017 22:03:35 +0000") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:213015 Archived-At: > 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? > 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! ] > 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). > 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. > 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. Stefan