From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: defvar'ing constants Date: Fri, 24 Jun 2005 05:54:41 +0200 Message-ID: Reply-To: Juanma Barranquero NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1119585297 11937 80.91.229.2 (24 Jun 2005 03:54:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 24 Jun 2005 03:54:57 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 24 05:54:50 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DlfHD-0005yW-Vz for ged-emacs-devel@m.gmane.org; Fri, 24 Jun 2005 05:54:48 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DlfOB-0001yy-6H for ged-emacs-devel@m.gmane.org; Fri, 24 Jun 2005 00:01:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DlfJb-00087h-S1 for emacs-devel@gnu.org; Thu, 23 Jun 2005 23:57:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DlfJM-0007yC-Ek for emacs-devel@gnu.org; Thu, 23 Jun 2005 23:57:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DlfJL-0007xO-OQ for emacs-devel@gnu.org; Thu, 23 Jun 2005 23:56:59 -0400 Original-Received: from [64.233.182.207] (helo=nproxy.gmail.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DlfKb-0000H2-UD for emacs-devel@gnu.org; Thu, 23 Jun 2005 23:58:18 -0400 Original-Received: by nproxy.gmail.com with SMTP id i2so77009nfe for ; Thu, 23 Jun 2005 20:54:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=MY5HHEWSVa/8m0XFPBTOGlTumGKMTvr5g//TUkskGHIUmpLj6StFn7ifWVNkBfvNMmiTJDIZuOpRGrac5X7SoVaxelhbCiY0dEIZJrWsj7cNDR8x8lKTOW4HEfjNDdEHs2daWznJ9bGqQ1KJNk9iMBnjdcyc/GVj5zGj/zGXtXE= Original-Received: by 10.48.4.20 with SMTP id 20mr50936nfd; Thu, 23 Jun 2005 20:54:41 -0700 (PDT) Original-Received: by 10.48.250.5 with HTTP; Thu, 23 Jun 2005 20:54:41 -0700 (PDT) Original-To: Emacs Devel Content-Disposition: inline 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:39397 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:39397 *** Welcome to IELM *** Type (describe-mode) for help. ELISP> (defvar :k) :k ELISP> (defvar :k 1) :k ELISP> (defconst :k 1) *** Eval error *** Attempt to set a constant symbol: :k ELISP> (set :k :k) :k ELISP> (set :k 1) *** Eval error *** Attempt to set a constant symbol: :k ELISP> (set-default :k :k) :k ELISP> (set-default :k 1) *** Eval error *** Attempt to set a constant symbol: :k ELISP>=20 For consistency: (defvar CONSTANT) ; should work (defvar CONSTANT ITS-VALUE) ; should work (defvar CONSTANT OTHER-VALUE) ; should fail The attached patch implements this behavior. I'm calling error directly, copying the error message from set_internal; another idea would be to allow the call to Fset_default to go through when NILP (tem) || (SYMBOL_CONSTANT_P (sym) && !EQ (tem, tail)) which avoid duplicating the error checking and the message, but doesn't seem clean to me. Opinions? --=20 /L/e/k/t/u Index: src/eval.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/src/eval.c,v retrieving revision 1.243 diff -u -2 -r1.243 eval.c --- src/eval.c=0923 Jun 2005 16:07:51 -0000=091.243 +++ src/eval.c=0924 Jun 2005 03:42:47 -0000 @@ -793,4 +793,8 @@ if (NILP (tem)) =09Fset_default (sym, Feval (Fcar (tail))); + else if (SYMBOL_CONSTANT_P (sym) + && !EQ (tem, tail)) + error ("Attempt to set a constant symbol: %s", + SDATA (SYMBOL_NAME (sym))); else =09{ /* Check if there is really a global binding rather than just a let