On Mon, 2019-04-22 at 12:04 -0400, Brian Goetz wrote: > > > > Ignoring first line, determine least number of leading whitespaces > > for all > > non-blank lines. > > > > String s = """ > > ................line 1.. > > ....................line 2. > > """; ==> 16 > > I think we should reconsider whether a non-blank first line means > that we should consider any indentation on the first line too. This > has the likely-beneficial side-effect that having a non-blank > character immediately following the """ effectively means "no > stripping."
I would go the other way and say that any non-blank first line should mean no stripping at all. A non-blank first line will always have at least an extra three characters of indentation, so won't line up with the rest of the string. (Ignoring some questionable (ab)use of 4+ width tabs.) I think it's a useful principle that automatic indentation stripping deals with the positioning of a string as a whole in 2D space in the source file, and if the relative positioning of each line appears to be inconsistently modified then this principle is violated. Telling users that they can encode this result: ....line 1 ....line 2 As either this: ` String s = """ line 1 line 2 """; ` Or this: ` String s = """ line 1 line 2 """; ` Would be hugely inintuitive imo. Non-empty first lines would still be useful as an opt-out. And I'd suggest a convention of using this opt-out by escaping the leading newline, thus making the first line effectively non-empty without messing up alignment in the source: ` String s = """\ line 1 line 2 """; ` gives: ......................line 1 ......................line 2 We can pull a similar trick to opt-out of any closing delimiter indentation influence: ` String s = """ line 1 line 2\ """; ` gives: line 1 line 2