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

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

Re: Working with constansts


From: Tassilo Horn
Subject: Re: Working with constansts
Date: Mon, 11 May 2009 09:39:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (gnu/linux)

Richard Riley <rileyrgdev@googlemail.com> writes:

Hi Richard,

> So really the question would be : why does Lisp not enforce constants
> being, err, constant?

I think it has something to do how lisp programs can be maintained.
What looks like a constant today may change in the future (maybe by
something totally unrelated like a new law).  With java for example, you
would change that constant in the code, rebuild and restart the
application.  With lisp you go to the repl and simply change the
constant without having to restart anything.

So you see that enforcing immutability of constants has drawbacks, too.
But the emacs byte-compiler issues a warning instead:

,----[ ~/test.el ]
| (defconst test-constant "CONSTANT")
| (setq test-constant "CHANGED")
`----

--8<---------------cut here---------------start------------->8---
% emacs -Q --batch -f batch-byte-compile test.el 
In toplevel form:
test.el:3:7:Warning: variable assignment to constant `test-constant'
Wrote /home/horn/test.elc
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo
-- 
Chuck Norris once rode a bull, and nine months later it had a calf. 





reply via email to

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