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: Mon, 5 Nov 2018 10:53:02 +0000 Message-ID: <20181105105302.GA10520@ACM> References: <20181101175953.GC4504@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1541415350 28056 195.159.176.226 (5 Nov 2018 10:55:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 5 Nov 2018 10:55:50 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 05 11:55:46 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 1gJcXp-0007Cz-Gy for ged-emacs-devel@m.gmane.org; Mon, 05 Nov 2018 11:55:45 +0100 Original-Received: from localhost ([::1]:34452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJcZv-00072b-SJ for ged-emacs-devel@m.gmane.org; Mon, 05 Nov 2018 05:57:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJcZ3-0006yP-Df for emacs-devel@gnu.org; Mon, 05 Nov 2018 05:57:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJcVu-0002XK-Tf for emacs-devel@gnu.org; Mon, 05 Nov 2018 05:53:50 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:42733 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1gJcVu-0001l3-II for emacs-devel@gnu.org; Mon, 05 Nov 2018 05:53:46 -0500 Original-Received: (qmail 35138 invoked by uid 3782); 5 Nov 2018 10:53:42 -0000 Original-Received: from acm.muc.de (p5B147DFB.dip0.t-ipconnect.de [91.20.125.251]) by colin.muc.de (tmda-ofmipd) with ESMTP; Mon, 05 Nov 2018 11:53:41 +0100 Original-Received: (qmail 10938 invoked by uid 1000); 5 Nov 2018 10:53:02 -0000 Content-Disposition: inline In-Reply-To: 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:231024 Archived-At: Hello, Stefan. On Thu, Nov 01, 2018 at 18:45:00 -0400, Stefan Monnier wrote: > > The third idea is to amend the reader so that whereas it now produces a > > form, in a byte compiler special mode, it would produce the cons (form . > > offset). So, for example, the text "(not a)" currently gets read into > Sounds good. I have the vague feeling that I mentioned it already, but > in case I haven't: please make sure the positions are character-precise > rather than line-precise, so that we can (eventually) ditch Edebug's > Elisp-reimplementation-of-the-reader which returns the same kind of info > (and needs character-precise location info). Actually this idea was not good; macros could not handle such a form without severe changes in the way macros work. (A research project, perhaps). I have come up with an improved scheme, which may well work. The reader would produce, in place of the Lisp_Objects it currently does, an object with Lisp_Type 1 (which is currently unused). The rest of the object would be an address pointing at two Lisp_Objects, one being the "real" read object, the other being a source position. The low level routines, like CONSP, and a million others in lisp.h would need amendment. But the Lisp system would continue with 8-byte objects, and the higher level bits (nearly all of it) would not need changes. The beauty of this scheme is that, outside of byte compilation, nothing else would change. One or two extra functions would be needed, such as `big-object' which would create a new-type object out of a source offset and "ordinary" object, `big-object-p', `big-offset' to get the source offset from a big object, and possibly one or two others. These would naturally be available to byte-compile-warn and friends, supplying the source position. To cope with the times when no source position would be available (e.g. in forms expanded from macros), the new variable `byte-compile-containing-form' would be bound at strategic places in the byte compiler. This would provide a fallback source position. The extra indirection involved in these "big objects" would naturally slow down byte compilation somewhat. I've no idea how much, but it might not be much at all. And yes, the source positions used would be character-precise. What do you think? > Stefan -- Alan Mackenzie (Nuremberg, Germany).