Chris's Wiki :: blog/programming/IndentationProblem Commentshttps://utcc.utoronto.ca/~cks/space/blog/programming/IndentationProblem?atomcommentsDWiki2014-02-25T21:53:59ZRecent comments in Chris's Wiki :: blog/programming/IndentationProblem.By DanielMartin on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:1ecc095b0a30bf4ff9a6925ddc78dea8ca0490eaDanielMartin<div class="wikitext"><p>JetBrains used this issue as an excuse for a bit of marketing:</p>
<p><a href="https://twitter.com/appcode/status/437896886649757696">https://twitter.com/appcode/status/437896886649757696</a></p>
</div>2014-02-25T21:53:59ZBy Chris Siebenmann on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:6427ac66f009858df7febd113b0f83004b1d088eChris Siebenmann<div class="wikitext"><p>David Magda: My view is that an ordinary style guide isn't sufficient
because people can and will deviate from it. Where Go wins is having a
way to automatically reformat all code to the style, so you can simply
say 'all code must be run through <code>gofmt</code> before being committed'.
It's the automated no-hassle enforcement that makes it work, reinforced
by social norms which themselves come about from using <code>gofmt</code> all the
time across most or all of the Go ecosystem.</p>
</div>2014-02-24T16:15:20ZBy Peter Donis on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:dba5d357d7d19857257222724892682f727af999Peter Donishttp://blog.peterdonis.com<div class="wikitext"><p>Yay, someone else who likes indentation being significant! My only beef is that <a href="http://blog.peterdonis.com/rants/delimiters-suck.html">delimiters suck</a>, so I do <em>not</em> like allowing them even if they are optional; plus, you shouldn't need them anyway (and of course Python doesn't have them).</p>
</div>2014-02-24T01:15:58ZFrom 31.151.153.51 on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:a0871b664002165188ba6bf4eb80cbda7029fb02From 31.151.153.51<div class="wikitext"><p>Guillaum, bugs will always exist, even with indentation (or are you guys suggesting python/go code has nog bugs?)</p>
<p>;-)</p>
</div>2014-02-23T15:48:40ZBy David Magda on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:a1d5a5cd85d3c1d1769dd15ea251573f4ec4f24bDavid Magdahttp://www.magda.ca/<div class="wikitext"><blockquote><p>The Go solution is to create a canonical formatting style for the language and then strongly encourage everyone to routinely convert their code to it.</p>
</blockquote>
<p>Java also has an official (?) <a href="http://www.oracle.com/technetwork/java/codeconv-138413.html">code convention guide</a>.</p>
<p>For statements, <a href="http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-142311.html">they give</a>:</p>
<blockquote><p>The if-else class of statements should have the following form:</p>
<pre>
if (condition) {
statements;
}
if (condition) {
statements;
} else {
statements;
}
if (condition) {
statements;
} else if (condition) {
statements;
} else {
statements;
}
</pre>
</blockquote>
</div>2014-02-23T12:41:52ZBy Guillaum on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:3a201d265024292546179529b5bafd20b61a17e8Guillaum<div class="wikitext"><p>31.151.153.51: I'm not sure that forcing the usage of curly braces totally fixes the issues, for example this piece of code, which is usually bugged because of the semi-colon:</p>
<pre>
for(...);
{
indented code
}
</pre>
<p>The indentation is correct, the curly braces are here, but the code is still bugged ? And it may be difficult for the compiler to tell you the issue, looks for example this code:</p>
<pre>
for(i = 0; i < 100; f(i++));
{
mutex_aquire_with_raii(mutex);
}
</pre>
<p>Do you want to acquire the mutex and apply "f" 100 times, or just one mutex acquire and 100 f call ?</p>
<p>The reason is because curly braces in C serves two purposes, the scope and the "indent" of statement, and this is highly confusing.</p>
<p>I never used "scope" in C/C++ for anything else than RAII, but because the scope syntax looks so close to the "indent" syntax, I'm always missing the fact that RAII is used during my code reviews.</p>
<p>So why not expressing the RAII syntax using something explicit AND expressing the "indent" level with indentation, and we solve both issues at the same time.</p>
</div>2014-02-23T11:38:21ZFrom 31.151.153.51 on /blog/programming/IndentationProblemtag:CSpace:blog/programming/IndentationProblem:9c8f51b688584ff72eda8e0e42b5a184361b7e0eFrom 31.151.153.51<div class="wikitext"><p>ahem, like Brian d Foy twits:</p>
<p>Buggy Apple iOS code illustrates why Perl always requires braces around if() statements</p>
<p><a href="https://twitter.com/briandfoy_perl/status/437358148010397696">https://twitter.com/briandfoy_perl/status/437358148010397696</a></p>
<p><em>if</em> C had required that, this indentation post would not have existed ;-)</p>
</div>2014-02-23T09:42:24Z