From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: defvar vs defconst
Date: Sat, 03 Aug 2013 11:37:31 +0800 [thread overview]
Message-ID: <87siyr78ck.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 871u6cjuce.fsf@gmail.com
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
next prev parent reply other threads:[~2013-08-03 3:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-02 9:49 defvar vs defconst Thorsten Jolitz
2013-08-02 21:49 ` Stefan Monnier
2013-08-03 3:37 ` Eric Abrahamsen [this message]
2013-08-03 7:43 ` Thorsten Jolitz
[not found] <mailman.2402.1375476850.12400.help-gnu-emacs@gnu.org>
2013-08-02 21:05 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87siyr78ck.fsf@ericabrahamsen.net \
--to=eric@ericabrahamsen.net \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).