<div dir="ltr">On Sun, Dec 20, 2015 at 8:12 AM, Alexander Regueiro via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div>There have also been a few votes against removing braces, but these seem to be reactionary. Could any of you perhaps clarify why you want to keep them, or is it just the “change is bad” stance?</div></div></blockquote><div><br></div><div>Having written a lot of Python code over the last seven years, I definitely prefer braces to significant whitespace, not because I enjoy looking at them or I want to indent my code incorrectly, but because they help my indent my code correctly and keep it correctly indented. The problems I&#39;ll describe below are all problems I have had in the real world when working with Python code.</div><div><br></div><div>Python suffers from the famous tab-spaces problem with significant indentation, which Guido listed is one of this &quot;Python Regrets&quot; in 2002. In short, Python considers tab characters to be worth 8 space characters, but very few if any people have their editor set to tab = 8 spaces. It actually doesn&#39;t matter what value you assign to tab. Sone people will have tab = 2 spaces, others 4, and I&#39;ve even worked with programmers who have it set to 5. The only defense against this is for everyone on a project to stick with either tabs or spaces, and this is why most Python programmers use spaces. But all it takes is one misconfigured text editor to introduce tabs into the project. They likely won&#39;t be caught by code review, and they may not immediately cause an error. But later on, they&#39;ll end up causing frustrating, difficult-to-diagnose errors. You also need to be paranoid about integrating code from other projects, because they might use tabs.</div><div><br></div><div>You could try to prevent this is Swift by banning the use of either tabs or spaces in indentation. But this would put you in the middle of a holy war that has been going on for decades, and would be a huge distraction. Not only would you anger those who like either tabs or spaces, but you would anger those who use tabs for semantic indentation, spaces for alignment.</div><div><br></div><div>The other classic problem, though not as common as it once was, is that HTML doesn&#39;t preserve multiple spaces in a row by default. Not a problem when you put the code in preformatted blocks, but there are HTML contexts that will still mangle your code unexpectedly. For example, some Web mail systems out there will display plan-text emails using HTML.</div><div><br></div><div>My personal pet peeve with significant whitespace is that it makes refactoring code more tedious. Let&#39;s say I want to move an if statement out of a loop. I select the statement, cut it, move my text cursor out of the loop to where I want to insert it, make sure I&#39;m indented at the level I want to be, and paste. The first line gets pasted with the proper indentation. All the subsequent lines get pasted with their original indentation, which I now have to fix.</div><div><br></div><div>Which brings me to the reason why I like braces: They allow text editors to handle the indentation for me. I don&#39;t have to worry about it. In the above example, I can just paste the code, and all the lines are indented properly. If I get sent some code in an HTML context that mangles indentation, or code that contains tabs, I can paste it into my text editor, and the editor will indent it properly and remove all the tabs.</div><div><br></div><div>Critics of tabs tend to focus on the fact that they don&#39;t express anything not already expressed by indentation. But as I&#39;ve explained here, that&#39;s not quite true. They provide enough context to text editors to automatically format your code for you. Without them, text editors cannot perform certain formatting operations.</div><div><br></div><div>Additionally, I have heard tell that one of the original inspirations for Python&#39;s significant whitespace code were C bugs caused by programmers who omitted braces and relied on indentation for if statements. In other words, code like the goto fail bug. Swift already takes care of this by making the curly braces mandatory in if statements, so Swift code will not fall victim to the class of bugs that inspired significant whitespace.</div><div><br></div><div>Python on the other hand, is vulnerable to this kind of bug due to unintentional outdenting. Maybe a programmer, when moving a block, missed intending the last line of the block. Perhaps an errant finger hit the delete key, outdenting the last line of an if statement. Python will now execute this line unconditionally. The equivalent error in braces-based languages, accidentally deleting the closing brace, will just cause the code to not compile.</div></div></div></div>