3 ms·
i'm always curious, why keep brackets? if blocks can be implied by whitespace (that vi can handle for you), what do explicit brackets buy you in exchange for th
by brandonhsiao 12y ago
i'm always curious, why keep brackets? if blocks can be implied by whitespace (that vi can handle for you), what do explicit brackets buy you in exchange for the time it takes to type them?
- klibertp 12y agoEasy copypasteability. Yeah, I don't understand why this would be an advantage either, but that's an argument I see most often.
- munificent 12y agoExplicit delimiters compose inside expressions much more gracefully. This is the main reason Python doesn't allow multi-line lambdas: if you have some significant indentation inside another expression, it's hard to tell how the rest of the expression following the unindent should be formatted. CoffeeScript does handle this, but I've always felt it was a murky corner of the grammar.
- breuleux 12y agoYou can easily allow both, though. At worst you can simply turn off significant indent inside explicit delimiters.
- munificent 12y agoSure, but then you need to implement both ways to express the same thing, and then deal with the infinite arguments it will spawn between proponents of each camp.
- breuleux 12y agoTypically, what I do is just map the indent and dedent tokens directly to some suitable bracket pair, so the implementation is trivial. As for the infinite arguments, well, as a language designer, is that really your problem? I mean, that kind of stylistic argument is no different from the endless arguments about bracket placement in C-like languages, or comma placement, "a+b" versus "a + b", and so on. People quibble about the dumbest things, I say just let them.
- ryanthejuggler 12y agoI can't tell you how many times my IDE has "helpfully" tried to autoindent my CoffeeScript for various reasons. In CoffeeScript, if your indentation gets thrown off, your code is going to do something completely different. That's why I'm very appreciative of languages with brackets. I know in CoffeeScript I could use parentheses to surround indented parts (because everything is an expression), but it just looks wrong when I do it. I wish CS treated parentheses and curly braces as interchangeable in most cases, which they pretty much are.