[swift-evolution] Thoughts on replacing \() with $() or some other symbol

Jordan Rose jordan_rose at apple.com
Tue Jun 21 17:51:54 CDT 2016


> On Jun 21, 2016, at 15:26, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Tue, Jun 21, 2016 at 5:10 PM, Daniel Resnick via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> I also disagree for the same reasons that Gwynne and Brent mentioned: I find '\(...)' easy to read, fine to type, and consistent with other string escaping syntax.
> 
> Those are persuasive arguments. Consistency with other string escaping syntax is a huge plus. Moreover, now that I think about it, \r or \n isn't really a bother to type. The \( combination takes a little getting used to, but it's not absurdly terrible. I suppose we could consider \{} or even \[] instead of \() to alleviate the reach.

Gwynne and Brent indeed hit on the logic for the original design: backslash is already an escape character in strings. The parentheses () over another kind of delimiter were originally to match calls (string interpolation once generated direct calls to String initializers), but even without that it’s still something that’s used with expressions, while curly braces {} are used for general code blocks and square brackets [] are used with collections.

I’m strongly in favor of keeping things the way they are, both because I like it a fair bit and because it’d be another source-breaking change that would be very hard to migrate.

Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160621/0a9d5087/attachment.html>


More information about the swift-evolution mailing list