[swift-evolution] multi-line string literals
andrey at tarantsov.com
Mon Dec 14 16:14:42 CST 2015
> 2) using ' means that the string contents are unescaped/raw
I wonder if that's too subtle. Like Chris, I would prefer advanced knobs to be (i) more distinctive than ' vs ", and possibly (ii) only attached to the advanced string type.
> 5) the first line, if it contains only a newline, is removed entirely (this lets you just start your text on the next line)
> I'm wibbly wobbly about the last line containing only a newline. I'm not sure whether to err on the side of caution and assume it's intentional, or remove it as well. At the moment I'm leaning toward assuming it's intentional.
I'd say trim 'em all, because right now I'm using ` literals in Go tests and trimming them like crazy, and I don't remember ever using a heredoc without passing it through trim.
> 4) indentation erasure is from the least indented line (from start of line, not start of quote)
> I'm also not entirely sure what to do in the case of mixed indentation. I could absolutely see the leading indentation being tabs (with the editor displaying them as equivalent to 4 spaces), but the slight indentation of one to three characters being spaces.
Ideally, a tab character would be a syntax error in Swift, period. Eat it, Go.
More realistically, you want to issue a syntax error if all non-empty lines don't share a common whitespace prefix that entirely covers at least one of the whitespace prefixes.
> Here is the SQL example for reference to show what I mean:
To be fair, SQL doesn't care about the leading whitespace, so it would be quite fine with any sort of trimming we implement.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution