<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On Dec 25, 2015, at 11:53 AM, Dmitri Gribenko via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span>On Fri, Dec 25, 2015 at 9:07 AM, Jason Jobe via swift-evolution</span><br><span>&lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:</span><br><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Okay,</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>I would like to propose that Transducers be considered for addition to the Swift core.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>"Transducers are a powerful and composable way to build algorithmic transformations that you can reuse in many contexts…"</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>There are ways to build them w/out any language modification but they are not as efficient as alternative expressions.</span><br></blockquote><span></span><br><span>Hi Jason,</span><br><span></span><br><span>I was playing with a similar idea here:</span><br><span></span><br><span><a href="https://github.com/apple/swift/blob/master/test/Prototypes/CollectionTransformers.swift">https://github.com/apple/swift/blob/master/test/Prototypes/CollectionTransformers.swift</a></span><br><span></span><br><span>You wouldn't find the word 'transducer' there, but it is based on</span><br><span>similar principles, except it also allows you to optimize the AST of</span><br><span>the transformation, and it is structured in such a way that would</span><br><span>allow us to automatically parallelize the whole pipeline.</span><br><span></span><br></div></blockquote><div><br></div><div>It's great to see you experimenting with this!</div><div><br></div><div>It's unrelated but one comment in there jumped out at me:</div><div><table class="highlight tab-size js-file-line-container" 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;"><tr style="box-sizing: border-box;"><td id="LC187" class="blob-code blob-code-inner js-file-line" 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="highlight tab-size js-file-line-container" 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;"><tr style="box-sizing: border-box;"><td id="LC188" class="blob-code blob-code-inner js-file-line" 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="highlight tab-size js-file-line-container" 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;"><tr style="box-sizing: border-box;"><td id="LC189" class="blob-code blob-code-inner js-file-line" 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="highlight tab-size js-file-line-container" 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;"><tr style="box-sizing: border-box;"><td id="LC190" class="blob-code blob-code-inner js-file-line" 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;"><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; color: rgba(0, 0, 0, 0.298039); 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="blob-code blob-code-inner js-file-line" 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;"><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; color: rgba(0, 0, 0, 0.298039); 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="blob-code blob-code-inner js-file-line" 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></td></tr></tbody></table>
</span></td></tr><tr style="box-sizing: border-box;"><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; color: rgba(0, 0, 0, 0.298039); 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="blob-code blob-code-inner js-file-line" 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></td></tr></tbody></table></div><div>I agree this is sad, but also hope it is only a temporary situation (as with other performance related concerns). &nbsp;Any thoughts on that?</div><br><blockquote type="cite"><div><span>Dmitri</span><br><span></span><br><span>-- </span><br><span>main(i,j){for(i=2;;i++){for(j=2;j&lt;i;j++){if(!(i%j)){j=0;break;}}if</span><br><span>(j){printf("%d\n",i);}}} /*Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>&gt;*/</span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>