<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Do you mean a TupleLiteralConvertible? I’m also in favor of a ClosureLiteralConvertible (or FunctionLiteralConvertible).<div class=""><br class=""></div><div class="">Stephen<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 6, 2015, at 6:40 PM, Nikolai Vazquez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important" class="">When working with points, I’ll sometimes make a <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-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">typealias</code> to an integer tuple:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code class="language-swift hljs" 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-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">typealias</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Point</span> = (x: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>, y: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>)
</code></pre><p style="margin:0px 0px 1.2em!important" class="">However, if I want to add extended functionality to my <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-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">Point</code> type, I would have to change it to a <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-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">struct</code>, removing the ability to create one on the fly with a tuple.</p><p style="margin:0px 0px 1.2em!important" class="">I’m proposing a <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-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">TupleConvertible</code> protocol that allows initialization from a tuple directly.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code class="language-swift hljs" 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-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">struct</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Point</span>: <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">TupleConvertible</span> </span>{

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

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

    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">init</span>(tuple: (x: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>, y: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Int</span>)) {
        <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">self</span>.<span class="hljs-keyword" 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" class="">This would make it very easy to create new <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-radius:3px;display:inline;background-color:rgb(248,248,248)" class="">Point</code> instances.</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px" class=""><code class="language-swift hljs" 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-radius:3px;display:inline;background-color:rgb(248,248,248);white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> somePoint: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Point</span> = (<span class="hljs-number" style="color:rgb(0,128,128)">50</span>, <span class="hljs-number" style="color:rgb(0,128,128)">120</span>)
<span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">let</span> otherPoint = <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Point</span>(x: <span class="hljs-number" style="color:rgb(0,128,128)">50</span>, y: <span class="hljs-number" style="color:rgb(0,128,128)">120</span>)
</code></pre>
<div title="MDH:V2hlbiB3b3JraW5nIHdpdGggcG9pbnRzLCBJJ2xsIHNvbWV0aW1lcyBtYWtlIGEgYHR5cGVhbGlh
c2AgdG8gYW4gaW50ZWdlciB0dXBsZTo8ZGl2PmBgYHN3aWZ0PC9kaXY+PGRpdj50eXBlYWxpYXMg
UG9pbnQgPSAoeDogSW50LCB5OiBJbnQpPC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rp
dj48ZGl2Pkhvd2V2ZXIsIGlmIEkgd2FudCB0byBhZGQgZXh0ZW5kZWQgZnVuY3Rpb25hbGl0eSB0
byBteSBgUG9pbnRgIHR5cGUsIEkgd291bGQgaGF2ZSB0byBjaGFuZ2UgaXQgdG8gYSBgc3RydWN0
YCwgcmVtb3ZpbmcgdGhlIGFiaWxpdHkgdG8gY3JlYXRlIG9uZSBvbiB0aGUgZmx5IHdpdGggYSB0
dXBsZS48L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PkknbSBwcm9wb3NpbmcgYSBgVHVwbGVDb252
ZXJ0aWJsZWAgcHJvdG9jb2wgdGhhdCBhbGxvd3MgaW5pdGlhbGl6YXRpb24gZnJvbSBhIHR1cGxl
IGRpcmVjdGx5LjwvZGl2PjxkaXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+c3RydWN0IFBvaW50
OiBUdXBsZUNvbnZlcnRpYmxlIHs8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PiZuYnNwOyAmbmJz
cDsgdmFyIHgsIHk6IEludDwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyBp
bml0KHg6IEludCwgeTogSW50KSB7PC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7ICZuYnNwOyAmbmJz
cDsgc2VsZi54ID0geDwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyAmbmJzcDsgJm5ic3A7IHNlbGYu
eSA9IHk8L2Rpdj48ZGl2PiZuYnNwOyAmbmJzcDsgfTwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+
Jm5ic3A7ICZuYnNwOyBpbml0KHR1cGxlOiAoeDogSW50LCB5OiBJbnQpKSB7PC9kaXY+PGRpdj4m
bmJzcDsgJm5ic3A7ICZuYnNwOyAmbmJzcDsgc2VsZi5pbml0KHg6IHR1cGxlLngsIHk6IHR1cGxl
LnkpPC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7IH08L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2Pn08
L2Rpdj48ZGl2PmBgYDwvZGl2PjwvZGl2PjxkaXY+PGJyPjwvZGl2PjxkaXY+VGhpcyB3b3VsZCBt
YWtlIGl0IHZlcnkgZWFzeSB0byBjcmVhdGUgbmV3IGBQb2ludGAgaW5zdGFuY2VzLjwvZGl2Pjxk
aXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+bGV0IHNvbWVQb2ludDogUG9pbnQgPSAoNTAsIDEy
MCk8L2Rpdj48ZGl2PmxldCBvdGhlclBvaW50ID0gUG9pbnQoeDogNTAsIHk6IDEyMCk8L2Rpdj48
ZGl2PmBgYDwvZGl2PjwvZGl2PjxkaXY+PGJyPjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0" class="">​</div></div></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="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;" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>