Is there any real reason to use "const"?

Ali Çehreli acehreli at
Mon Jan 24 17:30:26 UTC 2022

On 1/24/22 04:31, Dennis wrote:

 > I never understood the idea of people always including {} braces in
 > if-statements and for-loops.
 > What idiot would write something like that,

Yeah, that thought disappears once one realizes that humans are 
mistake-making machines. :)

 > One day I had a single-line for-loop
 > body, and to fix an error I quickly added an `import` statement above
 > it, pushing the for-loop body outside the for-loop scope. Oops.

I've done its counterpart just two days ago by commenting out one line 
(in somebody else's code):

   foreach(i; 0..2)
     // foo();


Oops! Now bar() is executed multiple times.

I am saddened with this skipped-braces "optimization" because all that 
risk for just to skip writing two characters! Wow! Now... that's... 
interesting... :) Humans are really interesting...


More information about the Digitalmars-d mailing list