From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nikolaj Schumacher Newsgroups: gmane.emacs.help Subject: Re: Working with constansts Date: Tue, 12 May 2009 12:06:24 +0200 Message-ID: References: <87d4ahylp3.fsf@galatea.local> <000801c9d191$22a21340$0200a8c0@us.oracle.com> <874ovszuu3.fsf@galatea.local> <87zldkxicx.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 1242122827 12064 80.91.229.12 (12 May 2009 10:07:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 May 2009 10:07:07 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: pjb@informatimago.com (Pascal J. Bourguignon) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 12 12:06:58 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 1M3ot0-0006jj-0Q for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 12:06:58 +0200 Original-Received: from localhost ([127.0.0.1]:37637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3osz-00029T-0B for geh-help-gnu-emacs@m.gmane.org; Tue, 12 May 2009 06:06:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M3osW-00029L-Hm for help-gnu-emacs@gnu.org; Tue, 12 May 2009 06:06:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M3osV-000299-NK for help-gnu-emacs@gnu.org; Tue, 12 May 2009 06:06:27 -0400 Original-Received: from [199.232.76.173] (port=38310 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M3osV-000296-H9 for help-gnu-emacs@gnu.org; Tue, 12 May 2009 06:06:27 -0400 Original-Received: from dd18200.kasserver.com ([85.13.138.168]:38879) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M3osU-00055f-Te for help-gnu-emacs@gnu.org; Tue, 12 May 2009 06:06:27 -0400 Original-Received: from thursday (f051097222.adsl.alicedsl.de [78.51.97.222]) by dd18200.kasserver.com (Postfix) with ESMTP id A1B5F18098F2E; Tue, 12 May 2009 12:06:28 +0200 (CEST) In-Reply-To: <87zldkxicx.fsf@galatea.local> (Pascal J. Bourguignon's message of "Mon, 11 May 2009 08:29:34 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (darwin) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:64369 Archived-At: pjb@informatimago.com (Pascal J. Bourguignon) wrote: > Richard Riley writes: > >> 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. Certainly const in C doesn't mean the value is determined at compile time. It just means: "This variable shouldn't be modified after its initialization." And in fact, you can cast constness away in C++, so it really has nothing to do with execution versus compile time. It's just a helper for the developer to prevent side-effects. There really is no pressing requirement for the current behavior, the run-time just doesn't verify it. It does one thing, though: (setq xxx 'user) (defvar xxx 'library) xxx => 'user (setq xxx 'user) (defconst xxx 'library) xxx => 'library A tiny step towards enforcing the value. regards, Nikolaj Schumacher