On 7/11/2020 6:31 PM, Guido van Rossum wrote:

Hm... Just the fact that people have been arguing both sides so convincingly makes me worry that something bigger is amiss. I think we're either better off without `else` (since the indentation of `case _` cannot be disputed :-), or we have to revisit the reasons for indenting `case` relative to `match`. As MRAB said, it's a case of picking the least inelegant one.

The more I think about adjusting IDLE's smart indenter to indent case suites once, with 2 half size indents, the more I would prefer to special case 'match' to have no indent (if there were no suite allowed) than special case 'match' and 'case' to indent 1/2 Indent.

Problem 1. Indent increments can be set to an odd number of spaces! (.rst files use 3 space indents.)

Problem 2. Dedent (with Backspace) could no longer be the simple expression I expect it currently is, such as new-indent = current-indent spaces // current indent size. IDLE would have to search backwards to find the appropriate header line, which might not be the most recent one. A stack of indent (delta,size) pairs would have to be recalculated from the most recent non-indented compound header line when the cursor is moved around.

Note that current indent may not be an indent size multiple number due to PEP8 vertical alignments, such as with function parameters or arguments.3

if a:
    def fg(param1,  # comment
           param2, # 11 space indent
           | # Backspace moves cursor left 3 spaces.

The flexibility of the peg parser needs to be used with care because it can allow constructs that are difficult for people and non-peg code to read and process.

--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/SSP5EZIPOK74S26HF2GJZI4WJG7VJONZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to