SIP-XX: Dedented Multiline String Literals

@haoyi I now read the proposal in full and it does indeed discuss the alternatives I raised before.

But I am still a bit pained that we now use another lexical delimiter with '''. It does not feel very nice for a language that strives to be small and orthogonal in its features.

So maybe go back to using single " instead? The argument against is

  • This has the disadvantage that a single " isn’t very visually distinct when used for demarcating blocks of text, and separating them vertically from the code before and after

But I am not sure that’s a very strong point. Any editor or IDE would syntax-highlight strings, so you know their span by their color alone.

About embedded single-line string literals:

A slightly more lenient version would interpret a " as closing a multi-line string literal if

  • there’s only whitespace between the last EOL and it, and
  • there is no other " following anywhere on the same line.

That would allow any embedded single-line string without need for escapes.

A single " also has the advantage that one can easily refactor between single line and multi-line literals. The quotes would never need to change.

I feel the single" would tell a better story. Instead of having three string literals we only have one and a half. From now on it would always be single " for string literals, so we are effectively removing a syntactic feature. Triple quotes stay around only for backwards compatibility.

11 Likes