<div dir="ltr">Why not omit the operator:<div><br></div><div><font face="monospace, monospace">myFunc([T])</font></div><div><br></div><div>and only require it to disambiguate cases like "Any...":</div><div><br></div><div><font face="monospace, monospace">myFunc([T]...)</font></div><div><br></div><div>Ambiguous cases should be rather uncommon anyway.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 12, 2015 at 9:03 AM, Kevin Ballard via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>
<div><div>Yeah, except you'd never actually write myFunc([T]...), because you can just say myFunc(T) in that case. So it would really be used like myFunc(args...)<br></div>
<div> </div>
<div>@autoclosure isn't a keyword, it's an attribute. AFAIK we have no precedence for attributes on expressions, only on declarations. And I'd think we'd need to have a really compelling reason to start putting attributes on expressions, since that's kind of weird.<br></div>
<div> </div>
<div>-Kevin<br></div><div><div class="h5">
<div> </div>
<div>On Fri, Dec 11, 2015, at 11:20 PM, Arthur Ariel Sabintsev wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Just to make sure we're on the same page, your suggestion is the following:<br></div>
<div> </div>
<div>// Declaration<br></div>
<div>func myFunc(v: T...) {}<br></div>
<div> </div>
<div>// Call<br></div>
<div>myFunc([T]...)<br></div>
<div> </div>
<div>That seems quite ugly, no? I'd prefer the use of a keyword at that point, kind of like we have @autoclosure, but instead of declaring the keyword in the function definition, we use the keyword (e.g., @variadic) in the function call.<br></div>
<div> </div>
<div>Thoughts on that?<br></div>
<div><div> </div>
<div><div><div dir="ltr"><div><div dir="ltr"><div style="color:rgb(0,0,0);font-family:helvetica,arial"><span style="color:rgb(34,34,34)"><span style="font-family:arial,sans-serif">Best,</span></span><br></div>
<div style="color:rgb(0,0,0);font-family:helvetica,arial"> </div>
<div style="color:rgb(0,0,0);font-family:helvetica,arial"><span style="color:rgb(34,34,34)"><span style="font-family:arial,sans-serif">Arthur / <a href="http://sabintsev.com/" target="_blank">Sabintsev.com</a></span></span><br></div>
</div>
</div>
</div>
</div>
</div>
<div> </div>
<div><div>On Sat, Dec 12, 2015 at 2:15 AM, Kevin Ballard <span dir="ltr"><<a href="mailto:kevin@sb.org" target="_blank">kevin@sb.org</a>></span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><u></u><br></div>
<div><div>Using any operator at all is a problem. The only way that can work without conflict is if the operator returns some special type that is known to the compiler to represent a variadic call, but that doesn't seem like a great idea. What do you think of the ... suffix? That can't conflict with operators, and it matches the variadic function declaration.<span><span style="color:rgb(136,136,136)"></span></span><br></div>
<div> </div>
<div> </div>
<div><span><span style="color:rgb(136,136,136)">-Kevin</span></span><br></div>
<div> </div>
<div><div><div> </div>
<div>On Fri, Dec 11, 2015, at 11:12 PM, Arthur Ariel Sabintsev wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div>Thanks for your response. <br></div>
<div> </div>
<div>The reason this doesn't work is due to Swift's generic system as it allows a type T to be a anything, including arrays. The example that was used to delineate this concept to me was that of "Any...", which from within the variadic function, could be interpreted as T or [T]. The result is ambiguous in the current implementation, which is why some identifier syntax needs be passed along with an array to get this to work properly.<br></div>
<div> </div>
<div>As for the choice of operator, I'm open to suggestions. I wanted to use one that was familiar to other developers, so I chose the one that Ruby uses. <br></div>
<div> </div>
<div>Maybe a ~ would be better, or a keyword like @variadic?<br></div>
<div> </div>
<div> </div>
<div><div><div><div dir="ltr"><div><div dir="ltr"><div style="color:rgb(0,0,0);font-family:helvetica,arial"><span style="color:rgb(34,34,34)"><span style="font-family:arial,sans-serif">Best,</span></span><br></div>
<div style="color:rgb(0,0,0);font-family:helvetica,arial"> </div>
<div style="color:rgb(0,0,0);font-family:helvetica,arial"><span style="color:rgb(34,34,34)"><span style="font-family:arial,sans-serif">Arthur / <a href="http://sabintsev.com/" target="_blank">Sabintsev.com</a></span></span><br></div>
</div>
</div>
</div>
</div>
</div>
<div> </div>
<div><div>On Sat, Dec 12, 2015 at 1:54 AM, Kevin Ballard via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><u></u><br></div>
<div><div>You can't use * as suggested, because that conflicts with * as a prefix operator.<br></div>
<div> </div>
<div>You could probably get away with using a trailing ... in the call, as in<br></div>
<div> </div>
<div>func foo(xs: [Int]...) {<br></div>
<div> bar(xs...)<br></div>
<div>}<br></div>
<div> </div>
<div>I also wonder whether there's a reason Swift doesn't already support this. Maybe there's some desired future change to variadic arguments to improve performance (i.e. to avoid having to allocate an array) that wouldn't be compatible? Although I'm not sure what that would be. Maybe there's actually no barrier at all and it was just something that wasn't prioritized. It would be good to know either way.<br></div>
<div> </div>
<div>-Kevin<br></div>
<div><div><div> </div>
<div>On Fri, Dec 11, 2015, at 10:43 PM, Arthur Sabintsev via swift-evolution wrote:<br></div>
</div>
</div>
<blockquote type="cite"><div><div><div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Hi,<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"> </div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">I have put together a proposal for passing arrays to variadic functions (along the lines of Ruby’s Splay operator). <br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"> </div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Proposal: <a href="https://github.com/ArtSabintsev/swift-evolution/blob/master/proposals/array-variadic-function.md" target="_blank">https://github.com/ArtSabintsev/swift-evolution/blob/master/proposals/array-variadic-function.md</a><br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Pull Request: <a href="https://github.com/apple/swift-evolution/pull/52" target="_blank">https://github.com/apple/swift-evolution/pull/52</a><br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Bug Report: <a href="https://bugs.swift.org/browse/SR-128" target="_blank">https://bugs.swift.org/browse/SR-128</a> which led to this proposal<br></div>
<div style="font-family:Helvetica,Arial;font-size:13px;color:rgb(0,0,0);margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"> </div>
<div> </div>
<div><div style="font-family:helvetica,arial;font-size:13px"><div style="color:rgb(34,34,34);font-family:arial,sans-serif">Best,<br></div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif"> </div>
<div><span style="color:rgb(34,34,34)"><span style="font-family:arial,sans-serif">Arthur / <a href="http://sabintsev.com" target="_blank">Sabintsev.com</a></span></span><br></div>
</div>
</div>
</div>
</div>
<div><img style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-bottom:0px!important;margin-right:0px!important;margin-left:0px!important;padding-top:0px!important;padding-bottom:0px!important;padding-right:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/7545e67f5aa6c8c6d8c277e33cd83b700849803f2a74601bb4ae0ab9a31ba65c/8647470737a3f2f2777777e266163747d61696c65737562736f6e64756e647e236f6d6f20727f68797f266335346237316035626333673838356634613464633364653261663637316039333835673931313833623939383232616233653438356334346362693363626f28363437343730373337316336623662373737373737356236363136333734373466313639363366353733373536323733363666356634373536356634373562333636663466366230373237366638373937366237333133313336363333353637333236393339333033373338333133323336333236363635363536353331363636323633333133353330333633363332363733323335363533363332363133353331363533373332333933303336333933323636333133363331333233323332363236363639333833393333363336333339333662383336333433373334333733303337333333373331363333363632333636323335333733323333333033333330333333323333333433333331333333303333333536323333333633343337333536323333333733353336333536363334333633373336333233373339333633343336333536323335363633353336333433373336363233373337333633363336363233363636333033373335333633353636333636333335333733303337333536363334363333313334333833373336333533313337333633373338333633333636333733333331333733313336333133343331363733343632333233333336333433353334333233333330333333343335333233373332333733373336333536343334333533393333333933343334363233323333333233343331333533383336333333333336333633383337333433333333333733333333333633353331363433343632333233333336333433303337333533353337333333323336333533353334333333323636333333373336333733393336333636343338333333333333333533363336333333323336333633373339333733383337333633373333333433333333333436343334333433343333333533373330333333343632333233333332333433333336333833333337333533373337333533373337333533373336333233353334333333333335333436323332333333323334333733343330333333393333333136373337333433343634333636363339333333343333333436323332333333363334333333353338333333343337333433373335333733363636333133373335333333363636333433353331333333353634333633333332333433343634333533333332363633353337333336343331333533363336333436323332333333363334333833343337333733333334333636343332333333323337333336363339333433393335333233333331333733303335333733353338333533383334333933373331363533343636333633343338333633373333333833333336333733343335333433373332333533333334333136363331333633383337333633363336333733313635333033373334333633333636333236343334333633353336333033333332363633343632333233333336333433353335333233343331363633333634333136363330333733343636333433343337333533363336333833363331333733343336333933373330333533393335333336343336333333323335333333333339333633343632333233333336333433363636333233343332333333383333333636343336333733343337333733333337333533313337333633353338333333393336333133373330333333343634333333353337333633393334333833333339333733383336333933363339333533373334333533363338333733353636333733343334333433333333333433373336333333373334333233343337333333313334333133373334333333393335333833363334363233323333333233343337333633343632333333333334333433343632333333333334333433366236663037353635663f2f60756e6/open"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><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><img src="https://www.fastmailusercontent.com/proxy/726710b2fb991510c56a4bcbba6e2a533972b10bb5577d59c08811d7cc8e92c2/8647470737a3f2f2777777e266163747d61696c65737562736f6e64756e647e236f6d6f20727f68797f253139313639366635663936313933693436373562303234353366616332666132316567366531326638393530326236326264656537366536333465643560326f2836343734373037333731633662366235373233303330333233343331333033356233363437356233373536356634363736323739363436356235663536343736623737363636623666303735363566366335373037356634633135366431663462323336343835373534643737323734373734383638343436326630333136366634623233363439353137393530353137393436343335383532353435303334343734373333353536313634623233323433343336383731643564323533663936373533373464333438363364353730353462323336343136346637363433383739353736356437363433316532663264363434353466343337373633333735363137346631363634313436343835356430333165393337353737346434363334393734363535323536643635393535353837323632333167363731353462323336343834373436333834373336373537346232333234313535363635363739373536353639333335363431643235353431673564313532663462323332343533383333363035333432353464383437373434363733353037343637333037373634363033356634663434343433663633363731643167373731663937313433343462323336343737313431353337313334623233363436353733303334343534383336343435323538373033346432353167366636333133363632333033333332343236393633353535336631653234343431653537316736373666363431673435343436343833393733333264343431363236343434623233323430353637373734333435346631353366363436663535353333373462333334343f2f60756e6/open" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-bottom:0px!important;margin-right:0px!important;margin-left:0px!important;padding-top:0px!important;padding-bottom:0px!important;padding-right:0px!important;padding-left:0px!important"><br></div>
</div>
<div> </div>
<div>_______________________________________________<br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
<div> </div>
</blockquote></div>
</div>
</div>
</blockquote><div> </div>
</div>
</div>
</div>
</blockquote></div>
</div>
</div>
</blockquote><div> </div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=6ZGE61OxINd5lLe2xYh9Ku-2BXbixWNr2nvfzp2IB1sZiDkFJhegVfF7ZTRiv8ctErdVcukTf0uP4KS1yU-2FpZPYmv2ycCBj-2FxRi1P9KdqhoP2qgGu-2BeeqJrmSeywAycY-2BMX36x4Egz-2FDmj6dAdb5Fk2HCwaQL5sYc-2Fs1b7jKjnFiQhl-2F-2Ffey5iiBUQX9WuEvHn94llVTJNm9WZleBrMihirqTddsGXTWT5i5HiuuL3R0g-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></div></div>
<br>_______________________________________________<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/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>