From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Working with constansts Date: Tue, 12 May 2009 13:43:52 +0200 Organization: Anevia SAS Message-ID: <7ciqk6czrb.fsf@pbourguignon.anevia.com> References: <87d4ahylp3.fsf@galatea.local> <000801c9d191$22a21340$0200a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1242132514 10553 80.91.229.12 (12 May 2009 12:48:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 May 2009 12:48:34 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 12 14:48:25 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M3rP1-0008SI-SJ for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 14:48:12 +0200 Original-Received: from localhost ([127.0.0.1]:56283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3rP1-0001bm-9s for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 08:48:11 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!proxad.net!feeder1-2.proxad.net!cleanfeed1-b.proxad.net!nnrp2-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:Zjk3NzU4YzNlZWJjM2MwODhkNjgyNTAwMWRjNzQ5MTg0NjYyZjgzNg== Original-Lines: 40 Original-NNTP-Posting-Date: 12 May 2009 13:43:52 MEST Original-NNTP-Posting-Host: 88.170.236.224 Original-X-Trace: 1242128632 news-2.free.fr 24000 88.170.236.224:53109 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:169114 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:64377 Archived-At: Nikolaj Schumacher writes: > Richard Riley wrote: > >>> Because this would incur overhead on every assignment, as it would have >>> to check whether the variable being assigned was declared as a constant. >>> Since this is so rarely the case, this overhead could be seen as mostly >>> wasted and unnecessary. >> >> I don't know enough about Lisp than I can only assume that in this case >> it can not be detected at compile time IF you compile to byte/p code. > > "Thanks" to dynamic scoping it cannot be caught at compile time. > > (defconst xxx nil) > > (defun change-xxx () > (setx xxx t)) ;; const or variable? > > (let ((xxx nil)) > (change-xxx)) It could be caught, if it was so defined by the language. For example, in the case of Common Lisp, it is forbidden to rebind lexically or dynamically a constant. The consequences are undefined when constant symbols are rebound as either lexical or dynamic variables. In other words, a reference to a symbol declared with defconstant always refers to its global value. Again, in both languages, a good solution is to mark constants with plus signs, so you're not tempted to rebind them. -- __Pascal Bourguignon__