by thargor90 · 3y ago · 0 comments
Yes it forces clean indentation, but it gives the writer the burden to take care of it. That sucks. Let the computer do the work.
An IDE with proper language support for a whitespace-aware language should be able to parse the AST figuring out the code structure from the indentation level; then it could reformat it at the proper indent level when you copy and paste it elsewhere, just like it does with a delimiter-based language.
No; it is not decidable where a block ends and the next line of the out block starts when there is no marker for block ends ('}', or 'END', etc).
No, it's not. The programming language grammar can reject things, but it cannot determine certain class of mistakes which explicit terminators ("}" and so on) can, which is why programs like `indent` existed for decades for other languages, but have yet to exist for Python which is already 30 years old.
If no one has cracked that particular nut for 30 years, you can't with a straight face claim that it is obviously possible. It looks more impossible with each passing year.
Just because you paste a bunch of code after `then` in Python doesn't mean all of it goes into `then`.
It's not rocket science, just following the language indentation rules for defining blocks. If the language parser can do it, why not the text editor?
Will it? Are you sure?
> Just copy it to the new position, and change the indentation level to that of the target position, maintaining the same block definition.
"Just" copy. "Just" manually re-indent it.
Remember, we're talking about an IDE automatically figuring out proper indentation for something.
> If the language parser can do it, why not the text editor?
Because constructs that are valid from the compiler's point of view may be ambiguous fro the program's point of view: https://news.ycombinator.com/item?id=34235121