From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Lisp watchpoints Date: Sat, 14 Nov 2015 17:29:07 -0500 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1447656703 6967 80.91.229.3 (16 Nov 2015 06:51:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Nov 2015 06:51:43 +0000 (UTC) Cc: John Wiegley , Eli Zaretskii , emacs-devel@gnu.org To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 16 07:51:34 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZyDdV-0003J8-Pi for ged-emacs-devel@m.gmane.org; Mon, 16 Nov 2015 07:51:34 +0100 Original-Received: from localhost ([::1]:45965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyDdU-0007gA-U0 for ged-emacs-devel@m.gmane.org; Mon, 16 Nov 2015 01:51:32 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxjJq-0000jn-19 for emacs-devel@gnu.org; Sat, 14 Nov 2015 17:29:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxjJm-0005fx-Pn for emacs-devel@gnu.org; Sat, 14 Nov 2015 17:29:13 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]:52236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxjJm-0005fm-JB; Sat, 14 Nov 2015 17:29:10 -0500 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id tAEMT72t022353; Sat, 14 Nov 2015 17:29:07 -0500 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 7F4FDAE0B5; Sat, 14 Nov 2015 17:29:07 -0500 (EST) In-Reply-To: (Noam Postavsky's message of "Sat, 14 Nov 2015 13:14:15 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5490=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5490> : inlines <4000> : streams <1538175> : uri <2082901> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.20 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:194509 Archived-At: >> Actually, I think it's not that complicated: >> - Look at the definition of SYMBOL_CONSTANT_P. > There is a comment on Lisp_Symbol's `constant' field saying "If the > value is 3, then the var can be changed, but only by `defconst'". > However, I can't find any code that uses this value. It's a mistake (I had such a thing working locally at some point but I dropped it before I installed the code in the repository): I just forgot to update the comment. > Is it safe to ignore? Yes. >> - Change its name to SYMBOL_SLOWWRITE_P. >> - Change the field it tests from being a boolean to being a 3-valued >> thingy, with values "fullspeed", "hooked", and "readonly". > Would it be sensible to implement "readonly" as "hooked" + some hook > that signals error on write? Could be, but I think I'd rather not take the risk that some advice could turn nil's value to something else than nil. IOW those vars currently marked as "read-only" should *really* be kept read-only. OTOH if we make sure that the "read-only" hook can't be overridden/changed/skipped by Elisp code, it might be fine. >> Maybe it'd be nice to make sure that "defvaralias" could be >> re-implemented on top of those hooks, even though I don't think such >> a reimplementation is desirable at this point. > To do that we'd have to trap reads as well as writes, right? I don't think so. We just need to keep the two vars "synchronized" so any assignment to one also changes the other. > Which could be useful for debugging too. I think a hook on variable reads is not a good idea. Fundamentally the issue is similar to the one for assignments, but the trade-offs work differently: - we currently don't have a CONSTANT_P check for reads, so adding a HOOKED_P check would incur an additional cost. - When debugging it's much less frequent to need to catch reads than writes. - The risk involved in running arbitrary Lisp code for a variable-read seems higher. So the cost and risks are higher whereas the expected benefits are lower. If/when dynamic-binding is the exception, maybe this could be reconsidered but there'd also need to be a compelling argument in favor. Stefan