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

Dave Yost Dave at Yost.com
Fri May 26 00:20:41 CDT 2017


I corresponded with Steve Bourne about here docs a while ago. He said

He said the only reason that indenting was not supported in his shell is that he didn’t think of it and neither did the other guys at Cambridge from whom he got the idea. And,

> I never considered the indent idea.  It’s a good idea although I don’t like the idea of post processing the temp file to remove the leading white space.  I agree the way it is now is not easy to look at and I can't think of a way to have the ident amount specified in advance of reading the document.


He liked this idea: The proposal could be extended so that if the open quote marking appears on a line by itself, the indentation on that line rules, and all lines through the close quote marking must have the same indenting.

  let foo = 
    """
    indent of initial quote
        dictates indentation
        and must match 
    indent of trailing quote
    """

If that proposal is adopted, then there are two alternatives if the open quote marking does not appear on a line by itself:
1. The indent is dictated by the close quote marking (current proposal). The coder can choose to take the parser performance hit, with apologies to srb.
2. There is no indenting and the close quote must appear flush left. (I don’t like this alternative.)

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170525/3ce44213/attachment.html>


More information about the swift-evolution mailing list