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: Mon, 11 May 2009 08:29:34 +0200 Organization: Informatimago Message-ID: <87zldkxicx.fsf@galatea.local> References: <87d4ahylp3.fsf@galatea.local> <000801c9d191$22a21340$0200a8c0@us.oracle.com> <874ovszuu3.fsf@galatea.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1242024156 14767 80.91.229.12 (11 May 2009 06:42:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 May 2009 06:42:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 11 08:42:28 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 1M3PDX-0000JE-I2 for geh-help-gnu-emacs@m.gmane.org; Mon, 11 May 2009 08:42:27 +0200 Original-Received: from localhost ([127.0.0.1]:58465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3PDX-000351-1Z for geh-help-gnu-emacs@m.gmane.org; Mon, 11 May 2009 02:42:27 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!proxad.net!feeder1-2.proxad.net!212.27.60.64.MISMATCH!cleanfeed3-b.proxad.net!nnrp5-2.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.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Cancel-Lock: sha1:MWMzMjZkNTg2NjQ3YTQxMjljMGNlNzEwYzBkNzMwNzBkMWYzYjRiZA== Original-Lines: 46 Original-NNTP-Posting-Date: 11 May 2009 08:29:36 MEST Original-NNTP-Posting-Host: 88.182.134.169 Original-X-Trace: 1242023376 news-1.free.fr 32384 88.182.134.169:62671 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:169075 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:64338 Archived-At: Richard Riley writes: > Which was basically my original question. > > If you go to the bother of having a "const xyz" implementation then it > seems to me slightly silly not to enforce it. > > Of course I understand if the answer is "history and that's the way it > is" but I would sympathise with a new programmer to Lisp that is > surprised he can modify a "const" especially if he came from a C/C++ > background where we all fully understand WHY consts are useful for the > programmer but the compiler also enforced it. The important point is that a lisp system is being programmed at the same time it is executed. Therefore redefining a constant may be taken into account, because it may be what the _programmer_ really means. In C, you would have to recompile the program before a change to a constant is taken into account, but it would be very possible to modify a constant: nothing prevents you to edit the C sources, recompile and relaunch. Some lisps (such as SBCL) do indeed issue a warning (actually a continuable error) when you try to change a constant. Usually, we apply a convention of naming constants surrounding them with + signs: (defconst +xyz+ 42) so you notice immediately if you're doing something you don't mean when you write: (setq +xyz+ ...) This low-tech solution is good enough, so there's no much point in implementing further tests in the implementation. (But unfortunately, these conventions are not often respected in emacs lisp code). -- __Pascal Bourguignon__