[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.
- Working with constansts, Decebal, 2009/05/10
- RE: Working with constansts, Drew Adams, 2009/05/10
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/10
- Message not available
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/10
- Re: Working with constansts, Richard Riley, 2009/05/10
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/11
- Re: Working with constansts, Nikolaj Schumacher, 2009/05/12
- Message not available
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/12
- Re: Working with constansts, Nikolaj Schumacher, 2009/05/18
- Message not available
- Message not available
- Message not available
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/18
- Re: Working with constansts, Nikolaj Schumacher, 2009/05/18
- Message not available
- Re: Working with constansts, Barry Margolin, 2009/05/10
- Re: Working with constansts, Richard Riley, 2009/05/10