<div dir="ltr">Hi Dave,<div>I just filed <a href="https://bugs.swift.org/browse/SR-2303">https://bugs.swift.org/browse/SR-2303</a>.</div><div><br></div><div>Brainstorming: is it important that the init(stringInterpolation:) and init(stringInterpolationSegment:) requirements are on the same type? Perhaps it would work to separate these two requirements, allowing the segments to construct intermediate types, and only requiring the type adopting ExpressibleByStringInterpolation to implement init(stringInterpolation:).</div><div><br></div><div>This would be nice because it would be much easier for types which aren&#39;t enums to conform to ExpressibleByStringInterpolation. In my auto layout example (<a href="https://gist.github.com/jtbandes/9c1c25ee4996d2554375">https://gist.github.com/jtbandes/9c1c25ee4996d2554375</a>), the ConstraintCollection type is only an enum because it has to provide all the initializers, but it&#39;s strange that the cases are accessible publicly; ideally it would just be a struct with no public initializers besides init(stringInterpolation:). For example:</div><div><br></div><div><div>    enum InterpolationSegment&lt;T: InterpolationSegmentProtocol&gt; {</div><div>        case stringLiteral(String)</div><div>        case interpolatedValue(T)</div><div>    }</div><div><br></div><div>    protocol InterpolationSegmentProtocol {</div><div>        // Might want to implement init(stringInterpolationSegment:) for multiple types,</div><div>        // so we can&#39;t require a single associated value (same with ExpressibleByStringLiteral today)</div><div>    //    associatedtype Value</div><div>    //    init(stringInterpolationSegment value: Value)</div><div>    }</div><div><br></div><div>    protocol MyExpressibleByStringInterpolation {</div><div>        associatedtype Segment: InterpolationSegmentProtocol</div><div>        init(stringInterpolation: InterpolationSegment&lt;Segment&gt;...)</div><div>    }</div><div><br></div><div>    // Foo is constructed from a string interpolation containing only</div><div>    // String pieces and Foo.Segment pieces.</div><div>    struct Foo: MyExpressibleByStringInterpolation {</div><div>        struct Segment: InterpolationSegmentProtocol {</div><div>            init(stringInterpolationSegment value: Int) {}</div><div>            init(stringInterpolationSegment value: Double) {}</div><div>        }</div><div>        init(stringInterpolation: InterpolationSegment&lt;Segment&gt;...) {</div><div>            // ...</div><div>        }</div><div>    }</div><div><br></div><div>    let x: Foo = &quot;abc\(3)def&quot;</div><div>    // translated to</div><div>    Foo(stringInterpolation:</div><div>        .stringLiteral(&quot;abc&quot;),</div><div>        .interpolatedValue(.init(stringInterpolationSegment: 3)),</div><div>        .stringLiteral(&quot;def&quot;))</div></div><div><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Mon, Aug 8, 2016 at 5:57 PM, Dave Abrahams via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
on Sat Jul 30 2016, Jacob Bandes-Storch &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
<br>
&gt; In the past, there has been some interest in refining the behavior of<br>
&gt; ExpressibleByStringInterpolati<wbr>on (née StringInterpolationConvertible<wbr>), for<br>
&gt; example:<br>
&gt;<br>
</span>&gt; - Ability to *restrict the types that can be used* as interpolation segments<br>
&gt; - Ability to *distinguish the string-literal segments* from interpolation<br>
<span class="gmail-">&gt; segments whose type is String<br>
<br>
</span>Hi Jacob,<br>
<br>
I see you&#39;ve already filed a Jira for the second bullet.  Can you file<br>
one for the first one?  We&#39;re going to redesign<br>
ExpressibleByStringInterpolati<wbr>on for Swift 4 and solve these problems.<br>
<br>
Thanks,<br>
<span class="gmail-"><br>
&gt; Some prior discussions:<br>
&gt; - &quot;<wbr>StringInterpolationConvertible and StringLiteralConvertible inheritance&quot;<br>
&gt; <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160516/017654.html" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>pipermail/swift-evolution/<wbr>Week-of-Mon-20160516/017654.<wbr>html</a><br>
&gt; - Sub-discussion in &quot;Allow multiple conformances to the same protocol&quot;<br>
&gt; <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160606/020746.html" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>pipermail/swift-evolution/<wbr>Week-of-Mon-20160606/020746.<wbr>html</a><br>
&gt; - &quot;<wbr>StringInterpolationConvertible<wbr>: can&#39;t distinguish between literal<br>
&gt; components and String arguments&quot;  <a href="https://bugs.swift.org/browse/SR-1260" rel="noreferrer" target="_blank">https://bugs.swift.org/browse/<wbr>SR-1260</a><br>
&gt; / rdar://problem/19800456&amp;<wbr>18681780<br>
&gt; - &quot;Proposal: Deprecate optionals in string interpolation&quot;<br>
&gt; <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160516/018000.html" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>pipermail/swift-evolution/<wbr>Week-of-Mon-20160516/018000.<wbr>html</a><br>
&gt;<br>
&gt; About Swift 4, Chris wrote:<br>
&gt;<br>
</span>&gt;&gt;  - *String re-evaluation:* String is one of the most important<br>
<span class="gmail-">&gt;&gt; fundamental types in the language.  The standard library leads have<br>
&gt;&gt; numerous ideas of how to improve the programming model for it, without<br>
&gt;&gt; jeopardizing the goals of providing a unicode-correct-by-default model.<br>
&gt;&gt; Our goal is to be better at string processing than Perl!<br>
&gt;<br>
&gt; I&#39;d be interested in any more detail the team can provide on this. I&#39;d like<br>
&gt; to talk about string interpolation improvements, but it wouldn&#39;t be wise to<br>
&gt; do so without keeping an eye towards possible regex/pattern-binding syntax,<br>
&gt; and the String refinements that the stdlib team has in mind, if there&#39;s a<br>
&gt; chance they would affect interpolation.<br>
&gt;<br>
&gt; Discuss!<br>
&gt;<br>
&gt; -Jacob<br>
</span>&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
--<br>
-Dave<br>
<br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</font></span></blockquote></div><br></div></div>