From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Thoughts on getting correct line numbers in the byte compiler's warning messages Date: Sun, 11 Nov 2018 12:59:45 +0000 Message-ID: <20181111125945.GA6487@ACM> References: <20181106151143.GB4030@ACM> <20181107170036.GA4934@ACM> <20181107184708.GB4934@ACM> <20181108140843.GB5041@ACM> <20181108221311.GD5041@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1541941217 5409 195.159.176.226 (11 Nov 2018 13:00:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Nov 2018 13:00:17 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Michael Heerdegen , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 11 14:00:12 2018 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 1gLpLX-0001H8-Lz for ged-emacs-devel@m.gmane.org; Sun, 11 Nov 2018 14:00:11 +0100 Original-Received: from localhost ([::1]:42158 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLpNe-0004vk-0C for ged-emacs-devel@m.gmane.org; Sun, 11 Nov 2018 08:02:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLpMt-0004vU-Vm for emacs-devel@gnu.org; Sun, 11 Nov 2018 08:01:36 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLpMl-0006Nc-Om for emacs-devel@gnu.org; Sun, 11 Nov 2018 08:01:35 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:10651 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gLpMl-0006ER-Bx for emacs-devel@gnu.org; Sun, 11 Nov 2018 08:01:27 -0500 Original-Received: (qmail 80443 invoked by uid 3782); 11 Nov 2018 13:01:14 -0000 Original-Received: from acm.muc.de (p5B14619F.dip0.t-ipconnect.de [91.20.97.159]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 11 Nov 2018 14:01:12 +0100 Original-Received: (qmail 6566 invoked by uid 1000); 11 Nov 2018 12:59:45 -0000 Content-Disposition: inline In-Reply-To: <20181108221311.GD5041@ACM> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 193.149.48.1 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:231071 Archived-At: Hello, Stefan. On Thu, Nov 08, 2018 at 22:13:11 +0000, Alan Mackenzie wrote: > On Thu, Nov 08, 2018 at 12:02:01 -0500, Stefan Monnier wrote: [ .... ] > OK. I've hacked together some basic infrastructure in alloc.c, lread.c, > print.c, and lisp.h. I can now read a small test file and get back the > form with "located symbols". I've called the new function which does > this read-locating-symbols, but that might want to change. > As soon as I've sorted out SYMBOLP and XSYMBOL, I'll create a new branch > under /scratch, commit what I've got, and then we can play with it. I've now got this working, and created the new, optimistically named, branch /scratch/accurate-warning-pos. To use this, do something like: M-: (setq bar (read-locating-symbols (current-buffer))) with point at the beginning of a (smallish) buffer. The following form, from Roland Winkler's bug #9109, works well: (unwind-protect (let ((foo "foo")) (insert foo)) (setq foo "bar")) . (car bar), for example, is now a "located symbol". Direct symbol functions are "protected" by an enabling flag located-symbols-enabled. This is needed, partly to minimise the run time taken when the facility is not being used, but more pertinently to enable Emacs to build without a segfault. Currently this flag guards only SYMBOLP and XSYMBOL. So, try M-: (symbolp (car bar)). This is nil. But M-: (let ((located-symbols-enabled t)) (symbolp (car bar))) is t. Similarly, set, symbol-value, symbol-function, symbol-plist need that flag to be non-nil. > > > One thing we'd need to watch out for is using equal, not eq, when we > > > compare symbols. (eq 'foo #) will surely > > > be nil, but (equal ....) would be t. Same with member and memq. > > Indeed. `equal' has been enhanced so that M-: (equal (car bar) 'unwind-protect) is t. Additionally, there are defuns only-symbol-p, located-symbol-p, located-symbol-sym, located-symbol-loc, which do the obvious. > > > We'd also need to make sure that the reader's enabling flag for creating > > > these extended symbols is bound to nil whenever we suspend the byte > > > compiler to do something else (edebug, for example). > > Rather than a dynamically-scoped var, it might be a better option to > > either use a new function `read-with-positions`, or else use an > > additional argument to `read`. As noted above I've currently got a rather untidy mixture of these two approaches. There's a lot left to do, but this is a start. Incidentally, I timed a make bootstrap in this branch, comparing it with master. The branch was ~0.5% slower. This might be real, it might just be random noise. Comments and criticism welcome! > > Stefan -- Alan Mackenzie (Nuremberg, Germany).