[swift-evolution] multi-line string literals

Chris Lattner clattner at apple.com
Thu Dec 24 21:50:49 CST 2015

> On Dec 11, 2015, at 8:01 AM, Travis Tilley <ttilley at gmail.com> wrote:
> OK, I understand your problem better with that example. Perhaps a solution would be to have """ process escapes while ''' starts a "raw" string. This is very much in line with ruby's style of strings where processing isn't done within single quoted strings:
> irb(main):001:0> foo = 2
> => 2
> irb(main):002:0> "#{foo}"
> => "2"
> irb(main):003:0> '#{foo}'
> => "\#{foo}"
> (Ignore that \# at the end there; that's only because the interactive console returns a double quoted string. I assure you, the contents are unescaped.)
> If we go with this syntax for escaped and unescaped strings, then for consistency's sake it would make sense to have single-line single-quoted strings that don't escape and are "raw" strings like in ruby.
> CCing Chris Lattner here specifically because, in swift today, using single quotes gives you a warning to just use double quotes, so he might have a strong opinion on this one. The latest commit to Lexer.cpp was actually to add better handling of single quoted strings (and I think more warnings if I remember?).

I’m ok with repurposing single quoted strings for something else.  Making them be the canonical “do not process escapes” string would make sense to me.  They should be usable in both single line and multi-line forms.


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

More information about the swift-evolution mailing list