Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #104414
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: modifying local const variable run time |
| Date | Wed, 22 Feb 2017 15:20:52 -0800 |
| Organization | None to speak of |
| Lines | 23 |
| Message-ID | <lno9xtke23.fsf@kst-u.example.com> (permalink) |
| References | <c5e88b2a-20a5-4083-a40a-a17d57aa42f7@googlegroups.com> <20170222160611.91c1f3085d6c9e3571a68156@gmail.com> <3cba5f3c-735a-45b7-87f2-d03dd8a18720@googlegroups.com> <20170222173450.4fe314b3c852b242bb2dc35a@gmail.com> <ln1suqkul5.fsf@kst-u.example.com> <20170222183223.a4daa256d17cc9bfcc04d4b9@gmail.com> <lnshn6jesv.fsf@kst-u.example.com> <o8l1uk$eh$3@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="17193b87357f3199fd5654843cb49d05"; logging-data="3703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19js1072Zgn97TzNoeax7ta" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:7gV+JvUm84nlxEx6xJFWLVfM89Q= sha1:HqiXqTHObLIBLNARvxxnYs0Tb3Q= |
| Xref | csiph.com comp.lang.c:104414 |
Show key headers only | View raw
David Brown <david.brown@hesbynett.no> writes:
> On 22/02/17 18:50, Keith Thompson wrote:
[...]
>> Personally, I use "const" mostly to make code clearer, so it's
>> obvious at a glance to a human reader that a given object won't
>> be modified, and so that the compiler can diagnose any incorrect
>> attempt to modify it. If a compiler can use that information to
>> generate faster code, so much the better.
>
> Or more importantly, if the compiler can use that information to spot
> mistakes in the code - accidentally modifying the const object - then so
> much the better. That's why the "const" keyword is much better than a
> "const" comment would have been, even if the comment were equally
> readable to humans.
I believe you're repeating part of what I wrote: "... and so that the
compiler can diagnose any incorrect attempt to modify it".
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 06:39 -0800
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 16:06 +0100
Re: modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 07:26 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 16:31 +0100
Re: modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 07:43 -0800
Re: modifying local const variable run time Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-22 16:06 +0000
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 11:13 -0500
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 08:34 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 23:03 +0100
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 17:34 +0100
Re: modifying local const variable run time Robert Wessel <robertwessel2@yahoo.com> - 2017-02-22 10:52 -0600
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 17:52 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:33 -0800
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 15:50 -0500
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 13:13 -0800
Re: modifying local const variable run time Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-22 21:55 +0000
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 14:43 -0800
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:23 -0800
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 18:32 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:50 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 23:07 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 15:20 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-23 09:50 +0100
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 10:16 -0500
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:17 -0800
csiph-web