From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Riley Newsgroups: gmane.emacs.help Subject: Re: Working with constansts Date: Mon, 11 May 2009 03:36:13 +0200 Organization: aich tea tea pea dicky riley dot net Message-ID: 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 1242006101 16697 80.91.229.12 (11 May 2009 01:41:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 May 2009 01:41:41 +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 03:41:31 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 1M3KWJ-0006Q2-8O for geh-help-gnu-emacs@m.gmane.org; Mon, 11 May 2009 03:41:31 +0200 Original-Received: from localhost ([127.0.0.1]:42117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3KWI-0007Qy-Mw for geh-help-gnu-emacs@m.gmane.org; Sun, 10 May 2009 21:41:30 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!goblin1!goblin.stu.neva.ru!feeder.motzarella.org!news.motzarella.org!motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 89 Original-X-Trace: news.eternal-september.org U2FsdGVkX1/oAcN1GwqFztH8mRV+8i/h9YIZnh6uZp0X/2LfBvSAWppshfzxHdUkX9Iisz70reaJp+sfDX25z779FgBppc1AXhwll5n+6Sffm4TUJqtqYC8sr7K9Zw3zPVJIKiiBscl6BxcrYE89Mg== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Mon, 11 May 2009 01:36:15 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19RbBF+T9A3sNqrWwEQEgj9QPs3H88ZKjsLyFQ4UenFRA== Cancel-Lock: sha1:OIokJRmQoH2On2nFSmlqK9mqcSk= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) Original-Xref: news.stanford.edu gnu.emacs.help:169068 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:64331 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) writes: > 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... Hold on. I agree with concise and clean code. But blatant showing off with NO whitespace or use of return code is the sign of, frankly, a loony. > > >>> 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). 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. --