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: Warnings about keymaps Date: Tue, 15 Sep 2009 09:40:27 -0400 Message-ID: References: <83ocph26p7.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1253022061 5352 80.91.229.12 (15 Sep 2009 13:41:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Sep 2009 13:41:01 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 15 15:40:54 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MnYH0-0005yG-GR for ged-emacs-devel@m.gmane.org; Tue, 15 Sep 2009 15:40:46 +0200 Original-Received: from localhost ([127.0.0.1]:46122 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnYGz-0001bS-Rk for ged-emacs-devel@m.gmane.org; Tue, 15 Sep 2009 09:40:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MnYGr-0001Y8-AK for emacs-devel@gnu.org; Tue, 15 Sep 2009 09:40:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MnYGm-0001Vo-7d for emacs-devel@gnu.org; Tue, 15 Sep 2009 09:40:36 -0400 Original-Received: from [199.232.76.173] (port=57814 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MnYGl-0001Va-RS for emacs-devel@gnu.org; Tue, 15 Sep 2009 09:40:31 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:49877 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MnYGj-0000OL-35; Tue, 15 Sep 2009 09:40:29 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIEAN01r0pFpZBe/2dsb2JhbACBU9x/hBcFh3U X-IronPort-AV: E=Sophos;i="4.44,390,1249272000"; d="scan'208";a="45704224" Original-Received: from 69-165-144-94.dsl.teksavvy.com (HELO ceviche.home) ([69.165.144.94]) by ironport2-out.pppoe.ca with ESMTP; 15 Sep 2009 09:38:47 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 2E460B42D1; Tue, 15 Sep 2009 09:40:27 -0400 (EDT) In-Reply-To: (Glenn Morris's message of "Mon, 14 Sep 2009 22:45:19 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115352 Archived-At: >> It could, but it shouldn't complain about assignment to a constant, >> since the defvar will not perform any assignment. I.e. maybe a warning >> is OK, but not the warning we currently get. > How about this? Or perhaps the defvar should just be silently > optimized away, like the default-boundp test seems to be trying to do. This warning might be OK, but I have some issues with it: - most importantly: it doesn't solve the problem at hand which is how to get rid of the other warning. - what's its use? It's not like we've seen lots of bugs where people use both defconst and defvar for a variable. - Finally, if the defconst+defvar is really what you want to do (as in the present case where the defconst and the defvar both come from macros that we may not want to change), how do you silence the warning? Stefan > *** bytecomp.el 10 Sep 2009 06:22:30 -0000 2.258 > --- bytecomp.el 14 Sep 2009 23:30:56 -0000 > *************** > *** 4025,4032 **** > (let ((tmp (make-symbol "defconst-tmp-var"))) > `(funcall '(lambda (,tmp) (defconst ,var ,tmp)) > ,value)) > ;; `defvar' sets `var' only when unbound. > ! `(if (not (default-boundp ',var)) (setq-default ,var ,value)))) > (when (eq fun 'defconst) > ;; This will signal an appropriate error at runtime. > `(eval ',form))) > --- 4036,4046 ---- > (let ((tmp (make-symbol "defconst-tmp-var"))) > `(funcall '(lambda (,tmp) (defconst ,var ,tmp)) > ,value)) > + (if (memq var byte-compile-const-variables) > + (byte-compile-warn "attempt to defvar constant `%s' \ > + has no effect" var) > ;; `defvar' sets `var' only when unbound. > ! `(if (not (default-boundp ',var)) (setq-default ,var ,value))))) > (when (eq fun 'defconst) > ;; This will signal an appropriate error at runtime. > `(eval ',form)))