From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: defvar vs defconst Date: Sat, 03 Aug 2013 11:37:31 +0800 Message-ID: <87siyr78ck.fsf@ericabrahamsen.net> References: <871u6cjuce.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1375501063 20167 80.91.229.3 (3 Aug 2013 03:37:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Aug 2013 03:37:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Aug 03 05:37:44 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V5Sf2-0006fX-Hc for geh-help-gnu-emacs@m.gmane.org; Sat, 03 Aug 2013 05:37:44 +0200 Original-Received: from localhost ([::1]:42861 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5Sf2-0002mZ-3e for geh-help-gnu-emacs@m.gmane.org; Fri, 02 Aug 2013 23:37:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5Sem-0002mJ-CO for help-gnu-emacs@gnu.org; Fri, 02 Aug 2013 23:37:35 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V5Sec-0002WR-VU for help-gnu-emacs@gnu.org; Fri, 02 Aug 2013 23:37:28 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:55489) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V5Sec-0002WJ-PD for help-gnu-emacs@gnu.org; Fri, 02 Aug 2013 23:37:18 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V5SeU-0005LO-0L for help-gnu-emacs@gnu.org; Sat, 03 Aug 2013 05:37:10 +0200 Original-Received: from 221.216.167.20 ([221.216.167.20]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Aug 2013 05:37:10 +0200 Original-Received: from eric by 221.216.167.20 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 03 Aug 2013 05:37:10 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 22 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 221.216.167.20 User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:uUoWCft8GeWkH062Q83/rgnTwvo= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:92685 Archived-At: Thorsten Jolitz writes: > Hi List, > > when you define a variable that should not be touched/set by the user of > your library (which is most likely a programmer), but will be frequently > set to a new value by your own program - would you call that a VAR or a > CONST? > > (defconst ...) signals "don't touch this", which seems to the right > thing in this case, but OTOH it is a bit strange to call something a > constant that not only can be changed, but will actually be changed > quite often. In addition to the other answers, which make perfect sense, you can also look in existing libraries and see what other people do. I've found that pretty much all "internal" variables -- last-abbrev-location, org-capture-current-plist, basically any variables used to preserve state -- are defined with defvar. HTH, Eric