From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kelly Dean Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] (Updated) Run hook when variable is set Date: Wed, 18 Feb 2015 05:15:20 +0000 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1424236622 24907 80.91.229.3 (18 Feb 2015 05:17:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 18 Feb 2015 05:17:02 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Feb 18 06:16:51 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 1YNx0D-0007Zj-0W for ged-emacs-devel@m.gmane.org; Wed, 18 Feb 2015 06:16:49 +0100 Original-Received: from localhost ([::1]:48516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNx0C-0006Af-0W for ged-emacs-devel@m.gmane.org; Wed, 18 Feb 2015 00:16:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNx08-0006Aa-0L for emacs-devel@gnu.org; Wed, 18 Feb 2015 00:16:44 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNx03-0007AT-Ld for emacs-devel@gnu.org; Wed, 18 Feb 2015 00:16:43 -0500 Original-Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:33064) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNx03-00078k-Gk for emacs-devel@gnu.org; Wed, 18 Feb 2015 00:16:39 -0500 Original-Received: from mfilter10-d.gandi.net (mfilter10-d.gandi.net [217.70.178.139]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id AC15DA80C4; Wed, 18 Feb 2015 06:16:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter10-d.gandi.net Original-Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter10-d.gandi.net (mfilter10-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 3Ln1pzYkSnLi; Wed, 18 Feb 2015 06:16:37 +0100 (CET) X-Originating-IP: 66.220.3.179 Original-Received: from localhost (gm179.geneticmail.com [66.220.3.179]) (Authenticated sender: kelly@prtime.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 1BF7DA80AC; Wed, 18 Feb 2015 06:16:34 +0100 (CET) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4b98:c:538::195 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:183230 Archived-At: I wrote: > it now spends half the time doing garbage collection. I figured out how to solve the voidness problem without consing or specbinding every time a hooked variable is set, and without usurping a keyword to represent void. Simply use an uninterned symbol to represent void. Specifically: DEFSYM (Qvoid_sentinel, "void-sentinel"); DEFVAR_LISP ("void-sentinel", Vvoid_sentinel, doc: /* Representation of voidness for hooked variables. The value of this constant is an uninterned Lisp symbol that represents void when passed to or returned from `symbol-setter-function'. When a variable is hooked, Emacs can't distinguish between setting it to this value and making it unbound. Therefore, to prevent a difference of behavior for hooked and unhooked variables, don't set any variable to this value. */); Vvoid_sentinel = Fmake_symbol (build_string ("::void::")); XSYMBOL (Qvoid_sentinel)->declared_special = true; XSYMBOL (Qvoid_sentinel)->vetted = SYM_CONST; Then at the end of run_varhook: oldval = EQ (oldval, Qunbound) ? Vvoid_sentinel : oldval; newval = EQ (newval, Qunbound) ? Vvoid_sentinel : newval; newval = call4 (Vsymbol_setter_function, symbol, env, oldval, newval); return EQ (newval, Vvoid_sentinel) ? Qunbound : newval; Semantically, that's worse than consing or specbinding, but not as bad as usurping a keyword. Is it ok to do it that way?