[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Working with constansts
From: |
Nikolaj Schumacher |
Subject: |
Re: Working with constansts |
Date: |
Tue, 12 May 2009 12:06:24 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.93 (darwin) |
pjb@informatimago.com (Pascal J. Bourguignon) wrote:
> Richard Riley <rileyrgdev@googlemail.com> writes:
>
>> 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.
Certainly const in C doesn't mean the value is determined at compile
time. It just means: "This variable shouldn't be modified after its
initialization."
And in fact, you can cast constness away in C++, so it really has
nothing to do with execution versus compile time. It's just a helper
for the developer to prevent side-effects.
There really is no pressing requirement for the current behavior, the
run-time just doesn't verify it. It does one thing, though:
(setq xxx 'user)
(defvar xxx 'library)
xxx => 'user
(setq xxx 'user)
(defconst xxx 'library)
xxx => 'library
A tiny step towards enforcing the value.
regards,
Nikolaj Schumacher
- Re: Working with constansts, (continued)
- 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 <=
- 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
- Re: Working with constansts, Ralf Wachinger, 2009/05/13