From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3f92589f15917eec X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: =?ISO-8859-1?Q?Markus_Sch=F6pflin?= Newsgroups: comp.lang.ada Subject: Re: Simple Warnings Needs Date: Thu, 24 Feb 2011 09:26:35 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <8aaf3582-0cc1-4c5f-ab85-eeb7ba569d9e@glegroupsg2000goo.googlegroups.com> <8b826007-6846-4477-a6e0-91ad08b32bc7@p12g2000vbo.googlegroups.com> NNTP-Posting-Host: hzAn46cwLozSmDBblnAvDQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news2.google.com comp.lang.ada:18550 Date: 2011-02-24T09:26:35+01:00 List-Id: Am 23.02.2011 22:55, schrieb Martin: [...] > I seem to remember an article by Dewar explaining why constants can > rarely be optimized but I can't put my finger on it at the moment... There has been a GOTW article about this. It of course discusses C++, but most statements are also valid for other languages. See http://www.gotw.ca/gotw/081.htm. To quote from it's summary at the end: It's a common belief that const-correctness helps compilers generate tighter code. Const is indeed a Good Thing, but the point of this issue of GotW is that const is mainly for humans, rather than for compilers and optimizers. When it comes to writing safe code, const is a great tool that lets programmers write safer code with compiler checking and enforcement. Even when it comes to optimization, const is still principally useful as a tool that lets human class designers better implement handcrafted optimizations, and less so as a tag for omniscient compilers to automatically generate better code. Markus