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: Sun, 10 May 2009 20:17:08 +0200 Organization: Informatimago Message-ID: <874ovszuu3.fsf@galatea.local> 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 1241980899 21783 80.91.229.12 (10 May 2009 18:41:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 10 May 2009 18:41:39 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun May 10 20:41:30 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 1M3Dxp-0001fm-NU for geh-help-gnu-emacs@m.gmane.org; Sun, 10 May 2009 20:41:30 +0200 Original-Received: from localhost ([127.0.0.1]:33668 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3Dxo-0006f7-Sf for geh-help-gnu-emacs@m.gmane.org; Sun, 10 May 2009 14:41:28 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!feeder1-2.proxad.net!cleanfeed2-a.proxad.net!nnrp5-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.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Cancel-Lock: sha1:NDBhNTJlZjFjOWY5MGZkNmM5MTE5OTBhNmNhYWE3YzBkN2I3YjRlYw== Original-Lines: 67 Original-NNTP-Posting-Date: 10 May 2009 20:17:10 MEST Original-NNTP-Posting-Host: 88.182.134.169 Original-X-Trace: 1241979430 news-1.free.fr 24818 88.182.134.169:65273 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:169064 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:64328 Archived-At: Richard Riley writes: >> [I knew an excellent (in individual terms) Lisp programmer back in the 80s who >> never used any whitespace that wasn't strictly needed for the Lisp reader and >> never commented any code. He (almost) never hit the Return key. Needless to say, >> no one else could work with his code. He did use reasonable names, however, and >> he didn't use the same conditional (e.g. `if' or `cond') everywhere. He coded in >> the way that was easiest to him and that got the point across to the Lisp >> reader.] > > He sounds like a terrible programmer. Programmers that write for > themselves are a curse. Maintenance time exceeds initial development > time by factors of 10 or 100 in most cases. pprint. To me he sounds like a very good programmer. There's no point in doing something that a simple function can do for you... >> Perhaps you have another question: >> Q. Why isn't it enforced? A. Lisp. >> > > Not really. It's not a constant. Having the specific type and then being > able to modify it proves that. You would be as well sticking CONST as the > name prefix as far as the language goes. As clear. > > But yes, of course I agree with your comments on "intent". But it > strikes me that its no more effective than, say requiring a file called > "myconstants" that has a bunch of variables. > > So really the question would be : why does Lisp not enforce constants > being, err, constant? In the case of emacs lisp, it's because the constant is still refered to, even in compiled code, thru the constant name. So if the value bound to the symbol change, it will change instantaneously for all the functions that us it. If you consider that emacs is usually a long running process that the user is continuously modifying, it's rather a good thing: it means you don't have to recompile everything when you correct the value of a constant. But you asked about Lisp. We'd have to do a study of the numerous remaining lisp dialects still in existance, but to take the example of Common Lisp, its standard specifies that you shouldn't modify the value of a constant, and that implementations are free to do whatever they want if you do. Indeed, some implementation behave like emacs lisp (eg. clisp, which has basically the same architecture as emacs lisp: both use a virtual machine and a byte code compiler). On the other hand, in the case of sbcl, which uses a native code compiler, the constants are inlined and if you change them, it won't recompile automatically the code that depend on them, so you may get inconsistencies. But it doesn't matter, since you shouldn't do that anyways. If you really want to change the value of a constant, you should recompile your system and reload it. (Or else, don't use constants, so the new value of variables may be taken into account immediately without recompilation). -- __Pascal Bourguignon__