31 ms·
You're using a double standard, here: if the computer is good at indenting brace based languages, then it is equally good at indenting languages without braces
by zak_mc_kracken 12y ago
You're using a double standard, here: if the computer is good at indenting brace based languages, then it is equally good at indenting languages without braces just based on the grammar.
- mindslight 12y agoNot at all. In this case, by 'languages without braces' we mean languages where indentation is part of the grammar. Python's grammar includes explicit INDENT/DEDENT tokens. It is impossible to reindent this mangled python: if z: print 'a' print 'b'
- adrusi 12y agoWhy would it be improperly indented in the first place? How is removing the indentation any different from removing braces? Sure, when you paste code somewhere that expects prose (Facebook status updates, for example), it will consolidate consecutive whitespace and thereby remove the indentation, but you shouldn't be pasting code into a place like that anyway, because no matter what you do it'll be unreadable, and most people aren't going to be interested enough to put it into their editor to autoformat.
- mindslight 12y agoI did not make the value judgment you are arguing against.
- mixmastamyk 12y agoEditors know that a python line ending in a colon must be indented and so indent it automatically. It wouldn't be hard to use the same method to reindent it.
- unwind 12y agoNo, lines following a line ending in a colon must be indented. But the OP's point is that you can't know how many lines make up the indented block, since there is no explicit block-end-marker left if the indent is gone.
- balquhidder 12y ago>No, lines following a line ending in a colon must be indented. Except if you have, for example, an if statement. if x: y() is valid.
- mixmastamyk 12y agoYep, that's what I meant.