help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defvar vs defconst


From: Eric Abrahamsen
Subject: Re: defvar vs defconst
Date: Sat, 03 Aug 2013 11:37:31 +0800
User-agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.3 (gnu/linux)

Thorsten Jolitz <tjolitz@gmail.com> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]