[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Working with constansts
From: |
Drew Adams |
Subject: |
RE: Working with constansts |
Date: |
Sun, 10 May 2009 09:31:07 -0700 |
> I would like to work with constants in my elisp code. I thought that I
> could do this with defconst, but that doen not work.
> After: (defconst dummy "testing")
> The variable dummy has the value "testing".
> But after: (setq dummy "changed")
> The variable dummy has the value "changed".
> What am I doing wrong.
>From the Elisp manual:
"The difference between `defconst' and `defvar' is primarily a matter
of intent, serving to inform human readers of whether the value should
ever change. Emacs Lisp does not restrict the ways in which a variable
can be used based on `defconst' or `defvar' declarations. However, it
does make a difference for initialization: `defconst' unconditionally
initializes the variable, while `defvar' initializes it only if it is
void."
Nothing prevents a user or program from changing the value of a `defconst'
variable. Unless you somehow cripple Emacs Lisp, you can always find a way to
modify something. That's about the only constant. ;-)