[swift-evolution] multi-line string literals
ttilley at gmail.com
Thu Dec 10 20:01:14 CST 2015
On Thu, Dec 10, 2015 at 8:41 PM, Chris Lattner <clattner at apple.com> wrote:
> 1) What concrete syntax should be used? There are a lot of options in
> this space across a wide range of languages. C++ has raw strings, and this
> page has more examples:
I am open to any and all suggestions, though I've already stated my
personal fondness for python's style. ;)
> 2) Should escapes like \n be processed always, should they never be
> processed, or should they be processed by default but disable-able in the
I would want multi-line string literals to behave as much like normal
string literals as possible for consistency. To optimize for developer
happiness, to steal the ruby saying, unexpected behavior should be kept to
a minimum. If \n works in a normal string literal, it should work in a
multi-line string literal... even if you could just hit enter instead.
> 3) What other policy decisions make sense to expose on these literals?
> Since this will be the “powerful form of string literals”, it makes sense
> to be the place to put weird knobs that are seldom used but important in
> various cases.
I would have to depend entirely on you to inform me of both these knobs
and use cases. I'd love to hear about them, that's for sure.
My initial goal was the minimal possible work required to decrease the
noise of writing large blocks of multi-line text and not have to poke
around too much in the lexer and parser code (being completely unfamiliar
with the swift codebase, having it just become open source recently).
> I assume that this would tie into the existing literal convertible
> protocols, and if/when escaping is supported that it would support
> interpolation as well.
I actually wanted to re-use the same function for handling normal string
literals so that the functionality available would be exactly the same, and
the output would be the exact same `tok::string_literal`.
- Travis Tilley
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution