<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 Dec 25, 2015, at 11:15 AM, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""><br class="">Sent from my iPad</div><div class=""><br class="">On Dec 25, 2015, at 11:53 AM, Dmitri Gribenko via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><span class="">On Fri, Dec 25, 2015 at 9:07 AM, Jason Jobe via swift-evolution</span><br class=""><span class=""><<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</span><br class=""><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class="">Okay,</span><br class=""></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class="">I would like to propose that Transducers be considered for addition to the Swift core.</span><br class=""></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class="">"Transducers are a powerful and composable way to build algorithmic transformations that you can reuse in many contexts…"</span><br class=""></blockquote><blockquote type="cite" class=""><span class=""></span><br class=""></blockquote><blockquote type="cite" class=""><span class="">There are ways to build them w/out any language modification but they are not as efficient as alternative expressions.</span><br class=""></blockquote><span class=""></span><br class=""><span class="">Hi Jason,</span><br class=""><span class=""></span><br class=""><span class="">I was playing with a similar idea here:</span><br class=""><span class=""></span><br class=""><span class=""><a href="https://github.com/apple/swift/blob/master/test/Prototypes/CollectionTransformers.swift" class="">https://github.com/apple/swift/blob/master/test/Prototypes/CollectionTransformers.swift</a></span><br class=""><span class=""></span><br class=""><span class="">You wouldn't find the word 'transducer' there, but it is based on</span><br class=""><span class="">similar principles, except it also allows you to optimize the AST of</span><br class=""><span class="">the transformation, and it is structured in such a way that would</span><br class=""><span class="">allow us to automatically parallelize the whole pipeline.</span><br class=""><span class=""></span><br class=""></div></blockquote><div class=""><br class=""></div><div class="">It's great to see you experimenting with this!</div><div class=""><br class=""></div><div class="">It's unrelated but one comment in there jumped out at me:</div><div class=""><table class="tab-size js-file-line-container highlight" data-tab-size="8" style="box-sizing: border-box; border-collapse: collapse; border-spacing: 0px; tab-size: 8; color: rgb(51, 51, 51); font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px; -webkit-text-size-adjust: 100%;"><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box;" class=""><td id="LC187" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// As sad as it is, I think for practical performance reasons we should rewrite
<table class="tab-size js-file-line-container highlight" data-tab-size="8" style="white-space: normal; box-sizing: border-box; border-collapse: collapse; border-spacing: 0px; tab-size: 8; color: rgb(51, 51, 51); font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px;"><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box;" class=""><td id="LC188" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// the inner parts of the fork-join framework in C++. In way too many cases<table class="tab-size js-file-line-container highlight" data-tab-size="8" style="white-space: normal; box-sizing: border-box; border-collapse: collapse; border-spacing: 0px; tab-size: 8; color: rgb(51, 51, 51); font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px;"><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box;" class=""><td id="LC189" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// than necessary Swift requires an extra allocation to pin objects in memory
<table class="tab-size js-file-line-container highlight" data-tab-size="8" style="white-space: normal; box-sizing: border-box; border-collapse: collapse; border-spacing: 0px; tab-size: 8; color: rgb(51, 51, 51); font-family: Helvetica, arial, nimbussansl, liberationsans, freesans, clean, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px;"><tbody style="box-sizing: border-box;" class=""><tr style="box-sizing: border-box;" class=""><td id="LC190" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// for safe multithreaded access. -Dmitri</span></td></tr></tbody></table>
</span></td></tr><tr style="box-sizing: border-box;" class=""><td id="L190" class="blob-num js-line-number" data-line-number="190" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; white-space: nowrap; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; vertical-align: top; text-align: right; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px; cursor: pointer; -webkit-user-select: none;"></td><td id="LC190" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"></td></tr></tbody></table>
</span></td></tr><tr style="box-sizing: border-box;" class=""><td id="L189" class="blob-num js-line-number" data-line-number="189" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; white-space: nowrap; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; vertical-align: top; text-align: right; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px; cursor: pointer; -webkit-user-select: none;"></td><td id="LC189" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><br class=""></td></tr></tbody></table>
</span></td></tr><tr style="box-sizing: border-box;" class=""><td id="L188" class="blob-num js-line-number" data-line-number="188" style="box-sizing: border-box; padding: 0px 10px; width: 50px; min-width: 50px; white-space: nowrap; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; line-height: 18px; vertical-align: top; text-align: right; border-style: solid; border-color: rgb(238, 238, 238); border-width: 0px 1px 0px 0px; cursor: pointer; -webkit-user-select: none;"></td><td id="LC188" class="js-file-line blob-code-inner blob-code" style="box-sizing: border-box; padding: 0px 10px; position: relative; vertical-align: top; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre; overflow: visible; word-wrap: normal;"><br class=""></td></tr></tbody></table></div><div class="">I agree this is sad, but also hope it is only a temporary situation (as with other performance related concerns). Any thoughts on that?</div></div></div></blockquote><div><br class=""></div><div>There's the intermediate possibility of using SIL to write these, which will give exact control over when copies and retains happen without dropping down to C++ and dealing with the fragility of maintaining common ABIs between Swift/C++ functions and the loss of high-level optimization opportunity.</div><div><br class=""></div><div>-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><blockquote type="cite" class=""><div class=""><span class="">Dmitri</span><br class=""><span class=""></span><br class=""><span class="">-- </span><br class=""><span class="">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if</span><br class=""><span class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>>*/</span><br class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RoDF4MveSEMYBIqIJA6ub1g8cOZ-2BVYvqV-2FqygPhjPn-2FQrjELC4dPTdMexAwVUMD1jRqSf4cIwWkLhE9TwsHXlTGZOl1PQBsm5jTLADCv75JYTgfwKHL3KmGpYkqvkK8YhMs5pZ-2BqjUclWi9n-2F4u7298YEGHJDQ-2BMm95-2FlKjIdj2J7g05baFcSzm-2FocpTagUeH63mTZCXhCaNuRJB5eHptBLfYTUfHIxh4-2BZo41EcwE8-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="">
</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>