[swift-evolution] Brace syntax

Andrey Tarantsov andrey at tarantsov.com
Sun Dec 20 14:33:49 CST 2015

We're really wasting time here (I'm pretty sure that the core team isn't considering the possibility), but:

> 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 [...]

Go does just that, with great profit.

(gofmt turns all indentation into tabs, although I would argue that a better approach is to ban tabs and only ever allow spaces)

> Critics of [braces] tend to focus on the fact that they don't express anything not already expressed by indentation. But as I've explained here, that'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.

Your whole point is that indentation sometimes gets lost on copy/paste, and braces don't. But it's a strange argument. Why would you use an editor or email program that routinely loses your data (indentation in this case)? Why would you copy your code from a strange web page whose author didn't even bother to format it correctly?

It sounds like you're not using per-line copy/paste features in your editor, and you need to change your editor or editing habits.

But I take the resulting broader point: indentation-based editing skills are a bit harder to master.

> Python on the other hand, is vulnerable to this kind of bug due to unintentional outdenting.

This is actually true. I've experienced this in Python a few times. Second valid point, I suppose, although it has never been a problem to catch it in practice.


More information about the swift-evolution mailing list