<div dir="ltr">Overall this is an interesting idea but in practice I think what you’re looking for is more of scala implicit conversions. A way to define a conversion from one type to another so that when you cast the implicit conversion gets run for you. It’s much more flexible and gives you what you want without only working for tuples.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 7, 2015 at 1:02 AM John McCall via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Dec 6, 2015, at 4:07 PM, Nikolai Vazquez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><div><p dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">I was thinking it could work for variables that are already tuples but then that goes against Swift&#39;s strict typing. So really it should only be for tuple literals.<br></p></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div>I think this is an interesting idea, but I believe it’s not actually expressible in the current generics system without hard-coding the protocol to just 2-tuples.</div></div><div style="word-wrap:break-word"><div><br></div><div>John.</div></div><div style="word-wrap:break-word"><div><br><blockquote type="cite"><div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div dir="ltr">On Sun, Dec 6, 2015, 7:01 PM Stephen Celis &lt;<a href="mailto:stephen.celis@gmail.com" target="_blank">stephen.celis@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Do you mean a TupleLiteralConvertible? I’m also in favor of a ClosureLiteralConvertible (or FunctionLiteralConvertible).<div><br></div><div>Stephen<br><div><br><div><blockquote type="cite"></blockquote></div></div></div></div><div style="word-wrap:break-word"><div><div><div><blockquote type="cite"><div>On Dec 6, 2015, at 6:40 PM, Nikolai Vazquez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br></blockquote></div></div></div></div><div style="word-wrap:break-word"><div><div><div><blockquote type="cite"><div><div dir="ltr"><div><p style="margin:0px 0px 1.2em!important">When working with points, I’ll sometimes make a<span> </span><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">typealias</code><span> </span>to an integer tuple:</p><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);display:block!important;background-position:initial initial;background-repeat:initial initial"><span style="color:rgb(51,51,51);font-weight:bold">typealias</span> <span style="color:rgb(68,85,136);font-weight:bold">Point</span> = (x: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>, y: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>)
</code></pre><p style="margin:0px 0px 1.2em!important">However, if I want to add extended functionality to my<span> </span><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">Point</code><span> </span>type, I would have to change it to a<span> </span><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">struct</code>, removing the ability to create one on the fly with a tuple.</p><p style="margin:0px 0px 1.2em!important">I’m proposing a<span> </span><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">TupleConvertible</code><span> </span>protocol that allows initialization from a tuple directly.</p><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);display:block!important;background-position:initial initial;background-repeat:initial initial"><span><span style="color:rgb(51,51,51);font-weight:bold">struct</span> <span style="color:rgb(68,85,136);font-weight:bold">Point</span>: <span style="color:rgb(68,85,136);font-weight:bold">TupleConvertible</span> </span>{

    <span style="color:rgb(51,51,51);font-weight:bold">var</span> x, y: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>

    <span style="color:rgb(51,51,51);font-weight:bold">init</span>(x: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>, y: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>) {
        <span style="color:rgb(51,51,51);font-weight:bold">self</span>.x = x
        <span style="color:rgb(51,51,51);font-weight:bold">self</span>.y = y
    }

    <span style="color:rgb(51,51,51);font-weight:bold">init</span>(tuple: (x: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>, y: <span style="color:rgb(68,85,136);font-weight:bold">Int</span>)) {
        <span style="color:rgb(51,51,51);font-weight:bold">self</span>.<span style="color:rgb(51,51,51);font-weight:bold">init</span>(x: tuple.x, y: tuple.y)
    }

}
</code></pre><p style="margin:0px 0px 1.2em!important">This would make it very easy to create new<span> </span><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;display:inline;background-color:rgb(248,248,248)">Point</code><span> </span>instances.</p><pre style="font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;white-space:pre-wrap;overflow:auto;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em;color:rgb(51,51,51);background-color:rgb(248,248,248);display:block!important;background-position:initial initial;background-repeat:initial initial"><span style="color:rgb(51,51,51);font-weight:bold">let</span> somePoint: <span style="color:rgb(68,85,136);font-weight:bold">Point</span> = (<span style="color:rgb(0,128,128)">50</span>, <span style="color:rgb(0,128,128)">120</span>)
<span style="color:rgb(51,51,51);font-weight:bold">let</span> otherPoint = <span style="color:rgb(68,85,136);font-weight:bold">Point</span>(x: <span style="color:rgb(0,128,128)">50</span>, y: <span style="color:rgb(0,128,128)">120</span>)
</code></pre><div title="MDH:V2hlbiB3b3JraW5nIHdpdGggcG9pbnRzLCBJJ2xsIHNvbWV0aW1lcyBtYWtlIGEgYHR5c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cGxlOiAoeDogSW50LCB5OiBJbnQpKSB7PC9kaXY+PGRpdj4m
bmJzcDsgJm5ic3A7ICZuYnNwOyAmbmJzcDsgc2VsZi5pbml0KHg6IHR1cGxlLngsIHk6IHR1cGxl
LnkpPC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7IH08L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pn08
L2Rpdj48ZGl2PmBgYDwvZGl2PjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+VGhpcyB3b3VsZCBt
YWtlIGl0IHZlcnkgZWFzeSB0byBjcmVhdGUgbmV3IGBQb2ludGAgaW5zdGFuY2VzLjwvZGl2Pjxk
aXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+bGV0IHNvbWVQb2ludDogUG9pbnQgPSAoNTAsIDEy
MCk8L2Rpdj48ZGl2PmxldCBvdGhlclBvaW50ID0gUG9pbnQoeDogNTAsIHk6IDEyMCk8L2Rpdj48
ZGl2PmBgYDwvZGl2PjwvZGl2PjxkaXY+PGJyPjwvZGl2Pg==" style="min-height:0px;width:0px;max-height:0px;max-width:0px;overflow:hidden;font-size:0em;padding:0px;margin:0px"></div></div></div></div></blockquote></div></div></div></div><div style="word-wrap:break-word"><div><div><div><blockquote type="cite"><div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=5xu02FVv-2BCbxTLHpBsC0RVeXVC5uCln3pUIIeLTlIi3PNiwjZYG5DrLQWjxWyWV-2BHZxHS9coVxT4qg5XZrpnNkEtnUT1mw0mvnRMOOTtSkNEyelVeO8g4QkcRBcH2SEIr8NkH1VtgOTh-2FfPB3JM6WVYR-2Fbw56PRxDfLy6N0w7-2BAlxHGRf1GxjRTWsa8xw-2Fb4onLWQZ7E-2BvKGlf8eEaeNItqmQ6kz-2BonpL9JbecuUaQ0-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span> </span>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div></div></div></div></blockquote></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=hWKWvOREWCPT32eVzNXOV7yIWXgGOvlMtgjKbOieJnbynZhIfKgfI0wGokYSOOHaUYaYGpuMNFU8RC7wDOoxHGH-2BMfisiEbh-2FGwDRijp-2BlSMmcOhXoPNVza-2BOq-2FS9ejOeKcCC1bAQMvse3pPR8jMtOeRUHHbB-2BWgIcCG046d-2FbuG-2B5ylFcNNcrKRIfPckkWa2-2Bb7-2F0uJq5zSCV51h3PRifmcrcnewHNlTnHjfHrshbc-3D" alt="" width="1" height="1" border="0" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RVJ3oK8DhV2nk8GArr3gdK5PBOtDs1DlpDw-2FEOl1yXmaOclKukYDdiTb-2Bf4IwUYGFH-2B1M5rhwzFprJlZAF2gtBKZH-2BBscXl8MlUjMKJS3XFTkzLl7fJ-2BN7jWHgpERRpFCQ3i2U8Yra1i35pKnxKQF9kuEJgefTth0Afh2Hr8ItbOgA43g6dDQZGF1yo-2BPsyyGtubAObidHMwuZeVs1l6mw-3D-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>