<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 6, 2016, at 7:47 AM, Jean-Denis Muys 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div class=""><br class=""></div><div class="">I would like to suggest an additive evolution to Swift that might be in scope of phase 1 of Swift 4 (because it might have an impact on the ABI).</div></div></div></blockquote><div><br class=""></div>How would you expect this to have an impact on ABI?</div><div><br class=""></div><div>Mark</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">The idea is to extend the pattern matching abilities of Swift to enable a recursive programming style that’s very common in languages such as Lisp, ML, or Prolog on a collection that is processed as a list. By analogy to ML, Swift could do that on tuples, or on arrays, or on any similar, perhaps new, data type. This would allow the following for example:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> listOfDifferenceOfListElements (list: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">List</span><span style="font-variant-ligatures: no-common-ligatures" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">&gt;) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo; min-height: 16px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">switch</span><span style="font-variant-ligatures: no-common-ligatures" class=""> list {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘〙</span><span style="font-variant-ligatures: no-common-ligatures" class="">: {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘〙</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〙</span><span style="font-variant-ligatures: no-common-ligatures" class="">: {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〙</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a, let b </span><span style="line-height: normal; font-family: 'Apple Symbols'; font-variant-ligatures: no-common-ligatures;" class="">⫸</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> tail </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〙</span><span style="font-variant-ligatures: no-common-ligatures" class="">: {</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〘</span><span style="font-variant-ligatures: no-common-ligatures" class=""> a-b </span><span style="line-height: normal; font-family: 'Hiragino Sans'; font-variant-ligatures: no-common-ligatures;" class="">〙</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="line-height: normal; font-family: 'Apple Symbols'; font-variant-ligatures: no-common-ligatures;" class="">⋙</span><span style="font-variant-ligatures: no-common-ligatures" class=""> sumDifferenceOfListElements(tail)</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div><div style="margin: 0px; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><span style="font-family: 'Hiragino Sans'; font-size: 14px;" class="">Where I deliberately used unusual Unicode characters to denote syntax that would need to be invented:</span></div><div class=""><br class=""></div><div class="">-&nbsp;<font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">〘〙 to denote the list-like data structure. It would be old style parenthesis if we wanted that to be Swift’s tuple, or the usual bracket if it was arrays</span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">-&nbsp;</span></font><span style="font-family: 'Apple Symbols'; font-size: 14px;" class="">⫸</span><span style="font-size: 14px; font-family: 'Hiragino Sans';" class="">&nbsp;to pattern-match the tail of the list,&nbsp;i.e. the list composed of any and all elements following whatever has been pattern-matched so far</span></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">-&nbsp;</span></font><span style="font-family: 'Apple Symbols'; font-size: 14px;" class="">⋙</span><span style="font-size: 14px; font-family: 'Hiragino Sans';" class="">&nbsp;to denote a list append operator.</span></div><div class=""><span style="font-size: 14px; font-family: 'Hiragino Sans';" class=""><br class=""></span></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">If we&nbsp;wanted the list data-type to be tuples, this&nbsp;would require the ability to build longer tuples from existing ones,&nbsp;i.e.&nbsp;</span></font><span style="font-size: 14px; font-family: 'Hiragino Sans';" class="">build (a, b, c) from a and (b, c), or from (a) and (b, c) (appending tuples). Array seems more suitable, however.</span></div><div class=""><span style="font-size: 14px; font-family: 'Hiragino Sans';" class=""><br class=""></span></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">So this post is to assess the interest in such a feature. Also note that while I have tried to have an occasional look at this mailing list in the&nbsp;past, due to its overwhelming volume, I may very well have missed a similar discussion in the past. In that case, I would appreciate a pointer.</span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">As someone who&nbsp;developed Lisp&nbsp;and Prolog software professionally in a rather distant past, with an ever renewed sense of wonder, I would very&nbsp;much love to be able to use that programming style again&nbsp;when&nbsp;it makes sense.</span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">If there is interest, I would be willing to write up an evolution proposal.</span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div class=""><font face="Hiragino Sans" class=""><span style="font-size: 14px;" class="">Jean-Denis Muys</span></font></div><div class=""><br class=""></div></div>_______________________________________________<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=""></body></html>