> On Jul 14, 2017, at 10:00, Alex Blewitt <[email protected]> wrote:
> 
>> On 13 Jul 2017, at 23:14, David Hart via swift-evolution 
>> <[email protected] <mailto:[email protected]>> wrote:
>> 
>>> 
>>> On 14 Jul 2017, at 00:21, Jordan Rose <[email protected] 
>>> <mailto:[email protected]>> wrote:
>>> 
>>> [Proposal: 
>>> https://github.com/apple/swift-evolution/blob/master/proposals/0182-newline-escape-in-strings.md
>>>  
>>> <https://github.com/apple/swift-evolution/blob/master/proposals/0182-newline-escape-in-strings.md>]
>>> 
>>> This is a tiny, tiny point amidst the broader discussions others are 
>>> having, but
>>> 
>>>>    • All whitespace characters between \ and the newline are disregarded.
>>> 
>>> Why? Why bother allowing whitespace characters between \ and the newline?
>> 
>> The reasoning is to be consistent with trailing whitespace in the rest of 
>> the code: to leave that to a linter instead. Or to see it differently, even 
>> with whitespace between \ and the newline, the programmer’s intent is still 
>> clear. Why generate an error?
> 
> For the same reason that code allows (e.g.) a comment at the end of the line; 
> you wouldn't expect (newline continuation) (comment) to mean the same thing 
> as if generic whitespace were added at the end. The convention in other 
> languages is that \ immediately precedes the line feed to indicate a 
> continuation, not that an orphan \ is valid on its own.
> 
> The reason that \(newline) is valid while \(otherchar)(newline) isn't is 
> because \ immediately precedes another character that it is escaping, and 
> it's possible that \(space) would have a meaning in the future, whereas 
> \(newline) won't.

I agree with Alex on this, although I would be happy to make it a warning 
rather than an error so that it doesn't block compilation.

The point about comments is also significant: we previously said that comments 
should generally be treated like whitespace (SE-0037 
<https://github.com/apple/swift-evolution/blob/master/proposals/0037-clarify-comments-and-operators.md>).
 This is a little different because it's still inside the string literal, but 
it's probably worth explicitly stating "we're still inside a string literal; 
you can't just put comments after the backslash".

Jordan

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to