[swift-evolution] [Review] SE-0168: Multi-Line String Literals

Ricardo Parada rparada at mac.com
Sat Apr 15 14:56:10 CDT 2017


> On Apr 15, 2017, at 3:28 PM, Thorsten Seitz <tseitz42 at icloud.com> wrote:
> 
>> Here is another example:
>> 
>> 	case .isExprSameType(let from, let to):
>> 		return """checking a value with optional type \(from) \
>> 			  against dynamic type \(to) \
>> 			  succeeds whenever the value is non-'nil'; \
>> 			  did you mean to use '!= nil'?\
>> 			  """
>> 
> 
> This only works because the lines have been indented by hand to match correctly which would not be the case with standard indentation used in a code editor which is a fixed multiple of spaces or tabs: the example had to add 2 spaces to the 2 tabs in this example to fix the indentation (requiring 8-space-tabs). In reality the example would look like follows (assuming 4-space-indentation but the problem is the same for other indentations):
> 
> case .isExprSameType(let from, let to):
>     return """checking a value with optional type \(from) \
>         against dynamic type \(to) \
>         succeeds whenever the value is non-'nil'; \
>         did you mean to use '!= nil'?\
>         """

That is perfectly fine too. I don't find this style confusing.  The 2nd, 3rd and 4th lines are stripped of their indentation according to the closing delimiter. And that is it.

>> I personally do not find this style confusing at all. 
> 
> The confusion arises over the leading newline: why does text directly following the opening triple quote have a newline while an empty line after the opening triple quote does not have a newline?

I think it is a good thing to have the option to start the line of text immediately after the opening delimiter or on the next line.

Regards,
Ricardo

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170415/b552e7fa/attachment.html>


More information about the swift-evolution mailing list