dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.02k stars 1.54k forks source link

Multiline strings should not allow backslashes to count as whitespace on first line. #19514

Open lrhn opened 10 years ago

lrhn commented 10 years ago

The multiline spec changed at some point to allow backslashes before whitespace characters on the first line, and still ignore the first line.

I see not need for this complication, and I think it should be removed again.

I can understand the wish to have a single newline at the start of a multiline string not count, so all the lines of the multiline string start at the same offset.

I can understand allowing invisible whitespace before the newline, because it's impossible to see and having it change your behavior would be bad.

I see absolutely no need for allowing visible backslashes. These characters are NOT part of the string, there is no need or even rationale for "string escaping" to work. If anything, if string escaping is allowed, I would expect the line to be part of the string proper.

What was the reason for making this change?

See also issue #14073 (which includes the text from before allowing backlashes) - we haven't specified what the "first line" of a string is, because we haven't specified what a "line" is in Dart source, and it isn't obvious.

If we change the NEWLINE production to allow "CR NL" as a single line terminator (which implementations already do, and will keep doing), then the WHITESPACE production no longer specifies single characters, and the text needs rewriting anyway. Is the sequence BACKSLASH CR BACKSLASH NL part of the "first line of whitespace"?

gbracha commented 10 years ago

Not sure we want to tamper with the standard over this kind of stuff, but we can take a look.


Set owner to @gbracha. Added Accepted label.