emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109864: Fix minor problems found


From: Wojciech Meyer
Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r109864: Fix minor problems found by static checking.
Date: Tue, 04 Sep 2012 19:51:35 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)

Paul Eggert <address@hidden> writes:

> On 09/03/2012 10:29 PM, Jan Djärv wrote:
>> Emacs does not use const much.
>
> It's typically easy to determine whether a local variable
> is never changed once initialized, simply by reading the code.
> So, for local variables, 'const' is typically more trouble than
> it's worth, as it adds a bit of noise to the code
> without much compensating value.
>
> For other things 'const' can be worthwhile sometimes,
> as it can help the reader understand constraints on the code,
> it can help avoid trivial programming errors,
> and it can help the compiler generate better code.
> Emacs tends to avoid 'const', though, partly
> because it predates 'const, and partly I expect because
> even in these other cases the readability advantage of
> omitting 'const' arguably trumps the minor advantages
> of using 'const'.

+1.

Modifying the code with const is easier, if it's const then the rest of
the function can assume that it will not be changed, and the user will
be forced either to read in full the body and remove carefully the const
modifier, or just stick to the existing constraints.

--
Wojciech Meyer
http://danmey.org




reply via email to

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