The main issue with that design is, even if it’s only bikeshedding here, that it creates ambiguity.
let a = "Hello, " "world!" To me that reads like the string constant a would contain "Hello, " and the literal "world!" sits somewhere in the middle of your code and is unused. Nothing signals to the developer that both string will be concatenated during compile time. -- Adrian Zubarev Sent with Airmail Am 23. April 2017 um 11:41:38, Xiaodi Wu via swift-evolution (swift-evolution@swift.org) schrieb: Sure, I can give an example. I'm not going to suggest that it'd win any awards, but: By restricting multiline literals to begin and end on distinct lines, the core team has established an interesting property. Namely, "literals" are delimited horizontally while """literals""" are delimited vertically. To enable hard wrapping, permit continuation of literals by apposition of consecutive literals. That is, "Hello, " "world!" would be equivalent to "Hello, world!". This single rule can be applied to either kind of string literal. That is: let a = "Hello, " "world!" let b = """ Hello, """ """ world! """ a == b // true It certainly permits elided newlines. It is the exact same rule applied to both types of literals. It preserves code indentation and does not require single-line string literals to support code stripping. I leave it to your judgement whether it works "equally well" and/or is "horrible." On Sun, Apr 23, 2017 at 04:13 Brent Royal-Gordon <br...@architechies.com> wrote: On Apr 22, 2017, at 8:12 AM, Xiaodi Wu <xiaodi...@gmail.com> wrote: On Sat, Apr 22, 2017 at 3:38 AM, Brent Royal-Gordon <br...@architechies.com> wrote: On Apr 21, 2017, at 11:48 AM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote: This goes to my question to David Hart. Isn't this an argument for a feature to allow breaking a single-line string literal across multiple lines? What makes this a use case for some feature for _multiline_ string literals in particular? Well, if you're breaking a string across several lines, you will want indentation stripping too. Are you suggesting we should also bring that feature to single-line string literals with escaped newlines? No, I am suggesting that whatever design is used for escaped newlines, if at all possible it should be equally apt for "strings" and """strings""" such that it will not require indentation stripping. Could you share an example of such a design? It doesn't have to be something you'd be happy to have in the language; it just needs to fit the following criteria: * Permits non-significant hard-wrapping in a string literal. * Works equally well with single and triple string literals. * Preserves code indentation, but does not require single string literals to do indentation stripping. * Is not horribly inconvenient. -- Brent Royal-Gordon Architechies _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution