[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Working with constansts
From: |
Pascal J. Bourguignon |
Subject: |
Re: Working with constansts |
Date: |
Mon, 11 May 2009 08:29:34 +0200 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
Richard Riley <rileyrgdev@googlemail.com> writes:
> Which was basically my original question.
>
> If you go to the bother of having a "const xyz" implementation then it
> seems to me slightly silly not to enforce it.
>
> Of course I understand if the answer is "history and that's the way it
> is" but I would sympathise with a new programmer to Lisp that is
> surprised he can modify a "const" especially if he came from a C/C++
> background where we all fully understand WHY consts are useful for the
> programmer but the compiler also enforced it.
The important point is that a lisp system is being programmed at the
same time it is executed. Therefore redefining a constant may be
taken into account, because it may be what the _programmer_ really
means.
In C, you would have to recompile the program before a change to a
constant is taken into account, but it would be very possible to
modify a constant: nothing prevents you to edit the C sources,
recompile and relaunch.
Some lisps (such as SBCL) do indeed issue a warning (actually a
continuable error) when you try to change a constant.
Usually, we apply a convention of naming constants surrounding them
with + signs:
(defconst +xyz+ 42)
so you notice immediately if you're doing something you don't mean
when you write:
(setq +xyz+ ...)
This low-tech solution is good enough, so there's no much point in
implementing further tests in the implementation.
(But unfortunately, these conventions are not often respected in emacs
lisp code).
--
__Pascal Bourguignon__
- RE: Working with constansts, (continued)
- 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 <=
- 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
- Re: Working with constansts, Nikolaj Schumacher, 2009/05/12
- Message not available
- Re: Working with constansts, Pascal J. Bourguignon, 2009/05/12
- Message not available
- Re: Working with constansts, Barry Margolin, 2009/05/13