From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#55338: Symbols with position are sometimes not symbols Date: Tue, 10 May 2022 19:28:10 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7092"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 55338@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 10 21:29:15 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noVXm-0001h2-3k for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 May 2022 21:29:14 +0200 Original-Received: from localhost ([::1]:36626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1noVXk-00072t-Mr for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 10 May 2022 15:29:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1noVXa-00072i-Sj for bug-gnu-emacs@gnu.org; Tue, 10 May 2022 15:29:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1noVXa-0003eU-Jw for bug-gnu-emacs@gnu.org; Tue, 10 May 2022 15:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1noVXa-0002EY-ES for bug-gnu-emacs@gnu.org; Tue, 10 May 2022 15:29:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 10 May 2022 19:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55338 X-GNU-PR-Package: emacs Original-Received: via spool by 55338-submit@debbugs.gnu.org id=B55338.16522109008533 (code B ref 55338); Tue, 10 May 2022 19:29:02 +0000 Original-Received: (at 55338) by debbugs.gnu.org; 10 May 2022 19:28:20 +0000 Original-Received: from localhost ([127.0.0.1]:35243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1noVWu-0002DZ-Ah for submit@debbugs.gnu.org; Tue, 10 May 2022 15:28:20 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:52353 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1noVWs-0002DJ-0R for 55338@debbugs.gnu.org; Tue, 10 May 2022 15:28:18 -0400 Original-Received: (qmail 65064 invoked by uid 3782); 10 May 2022 19:28:11 -0000 Original-Received: from acm.muc.de (p4fe15691.dip0.t-ipconnect.de [79.225.86.145]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 10 May 2022 21:28:10 +0200 Original-Received: (qmail 7222 invoked by uid 1000); 10 May 2022 19:28:10 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231866 Archived-At: Hello, Paul. On Mon, May 09, 2022 at 10:25:42 -0700, Paul Eggert wrote: > While looking into another issue I saw the code added a few months ago > for symbols with position, and noticed what looked to me to be a bug: > although (read-positioning-symbols "xyz") returns a symbol, (symbolp > (read-positioning-symbols "xyz")) returns nil. Yes. A symbol with position isn't a symbol, any more than a symbol is a function. But (functionp 'list) returns t, nevertheless. This doesn't appear to give rise to confusion (except, perhaps, in novices). > It seems that symbols with positions are symbols only if > symbols-with-pos-enabled is t; otherwise, they are not symbols. SWPs are not symbols. They merely give a result of t to symbolp. > Unfortunately this leads to confusing behavior such as the above. Why is this any more confusing than functionp returning t for a symbol? Perhaps the documentation for SWP could be firmed up a bit. > As I understand it, the symbols-with-pos-enabled variable is present for > performance reasons only. If this understanding is correct, I suggest > removing the variable and having symbols with positions always be > symbols. This is an interesting idea. It would increase the amount of space used by Emacs's symbols, though. Would this be important? > This would avoid the confusion. I think this could be done without > hurting CPU performance compared to the master branch when > symbols-with-pos-enabled is nil; see attached patch, which is relative > to master commit 6fc54786c3bb797068675d7eb7b500fb990bd04a. (The patch > is incomplete, as src/comp.c would need to be updated to match, but > that's merely turning the crank.) So in place of checking symbols-with-pos-enabled at each otherwise failed EQ operation, we need to check the "real symbol" of each symbol in such a comparison. How much faster or slower is, say, a bootstrap build (even without native compilation) with this proposed scheme? What about benchmarks which don't involve compilation? > Even if this patch is completed I have qualms about performance and > correctness of symbols with positions. The performance appears to be OK in tests of real world usage, with perhaps a maximum 1% to 2% slowdown observed. Benchmarking some test programs showed a greater slowdown. More benchmark results would be welcome. As for correctness, the code has been running for several months with just one or two pertinent bugs found in the byte compiler. They can be, and have been, corrected. Critically, the bug which gave rise to the mechanism, wrong line/column numbers being reported in compilation warning messages, has been fixed. > How about a new build-time flag --disable-symbols-with-pos that would > disable the feature, for people who don't want performance degraded > compared to Emacs 28, or who are unsure of the correctness > implications of the new feature? Symbols with position is NOT a user feature. It is (an essential part of) a bug fix. It seems inappropriate to offer an option not to fix a bug. > That should be easy to add, and I can look into adding it unless > there's objection. I object. I doubt it would be easy to add, since you'd have to resuscitate a fair amount of old code discarded from master some while ago. Maintaining two versions side by side would lead to maintenance complications. > Also, there should be a NEWS item about symbols with positions. No. Again, symbols with position is not a feature, and is not intended for use outside of the byte compiler. Although I suppose it could be used if anybody wrote some compiler-like feature for Lisp code, but such a hacker will know about SWPs without needing to read about them in NEWS. [ Patch snipped, but perused. ] -- Alan Mackenzie (Nuremberg, Germany).