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 the buffer positions in the byte compiler's warning messages. Date: Sun, 18 Sep 2016 17:38:51 +0000 Message-ID: <20160918173851.GB3576@acm.fritz.box> References: <20160918152303.GA3576@acm.fritz.box> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1474220384 5622 195.159.176.226 (18 Sep 2016 17:39:44 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 18 Sep 2016 17:39:44 +0000 (UTC) User-Agent: Mutt/1.5.24 (2015-08-30) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 18 19:39:40 2016 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 1blg3t-0007zd-Cw for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 19:39:29 +0200 Original-Received: from localhost ([::1]:51011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blg3q-0006ce-Hb for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 13:39:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blg3k-0006cZ-0h for emacs-devel@gnu.org; Sun, 18 Sep 2016 13:39:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blg3g-0006dP-Qc for emacs-devel@gnu.org; Sun, 18 Sep 2016 13:39:19 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:24173) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blg3g-0006cO-Gr for emacs-devel@gnu.org; Sun, 18 Sep 2016 13:39:16 -0400 Original-Received: (qmail 77994 invoked by uid 3782); 18 Sep 2016 17:39:13 -0000 Original-Received: from acm.muc.de (p548C6F28.dip0.t-ipconnect.de [84.140.111.40]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 18 Sep 2016 19:39:12 +0200 Original-Received: (qmail 5680 invoked by uid 1000); 18 Sep 2016 17:38:51 -0000 Content-Disposition: inline In-Reply-To: <20160918152303.GA3576@acm.fritz.box> 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 X-Received-From: 193.149.48.3 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:207570 Archived-At: Hello, Emacs. On Sun, Sep 18, 2016 at 03:23:03PM +0000, Alan Mackenzie wrote: > ######################################################################### > I've been trying to come up with a general solution to these problems. > What I have at the moment, which is rather vague, amounts to this: > After the reader has produced the form to be compiled and > read-symbol-positions-list, we combine these to produce a @dfn{shadow > form} with the same shape as the form, but where there's a symbol in the > form, there is a corresponding list in the shadow form, noting the > corresponding "position" in the form, and onto which warning/error > messages can be pushed. These can then be output at the end of the > compilation. > The info in the shadow form will allow the correct node corresponding to > one in the form to be found, thus correct line/column numbers in > messages are assured for normal code. Possibly a hash table will serve > somehow to speed up searches. > For transformed code (macro invocations, optimised forms, etc.), things > become more difficult. However, these transformations mostly leave most > of the cons cells in the form unchanged, just rearranging them somewhat. > So the "pointers" in the shadow form will continue to be associated with > them, enabling accurate warning messages even here. > Obviously, this mechanism would cause the byte compiler to run more > slowly. Whether or not this is significant or not would be down to > experience. > Comments? Actually, with a bit more thought, the above is totally over the top. What's needed is to construct a hash table whose key is a cons cell in the form which the reader has just built, and whose value is the position of the symbol in the car of that cons cell. OK, something is needed for vectors, too, and maybe one or two other things. This hash table can easily be built from the available information (the form and read-symbol-positions-list), and once the mechanism is seen to be working we could get the reader to produce this hash table directly. Then when we want to output a diagnostic, in addition to passing the string to byte-compile-warn, we also pass a cons cell representing the position we want output. This should work. -- Alan Mackenzie (Nuremberg, Germany).