brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 109 forks source link

Allow Multi-line String Literals with Double Quotes ("foo") #1370

Closed InnPatron closed 6 years ago

InnPatron commented 6 years ago

This issue is also filed as a consequence of #1369.

1369 is a bug in the compiler, but to me, the current behavior is not 'intuitive'. In addition, according to #639 and #972, triple quoted strings have various problems.

I want to hear the arguments for disallowing multi-line string literals with double quotes. As far as I'm aware, there is not any reason why double quoted strings cannot span multiple lines. I would further say that there should be NO formatting done to these multi-line string literals without a special delimiter.

Some interesting data points:

The change in syntax would be a quick change in the lexer, I would imagine.

blerner commented 6 years ago

Closing as not wanted. This was discussed way back in Pyret's history; #165 has a good chunk of the context there.

This is a fairly important change in the lexer, actually, and it results in much worse syntax highlighting, automatic indentation, and error messages to users. For our target audience, multi-line strings are nearly always mistakes. Novice students are still struggling with balancing delimiters, and having the lexer say "Oh that's ok, your string actually just extends for the rest of the file and we'll complain at the end of the file that you're missing a closing quote" leads to a very delocalized error message, that misleads students about where the problem actually is. The languages you've chosen as examples back that point up, actually: not one of them is friendly to novices, and their error messages are pretty horrible in general.

Having multi-line strings is useful, and no formatting is done to them unless they have a special delimiter. I agree -- that delimiter is three backticks.

TQS have implementation problems, yes, because their delimiters are three characters long, which makes things tough. But we've managed with them, and while I still don't like them much, they're useful to have in the few times that they're really needed.