<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 Jun 23, 2017, at 9:29 AM, Nevin Brackett-Rozinsky &lt;<a href="mailto:nevin.brackettrozinsky@gmail.com" class="">nevin.brackettrozinsky@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">This sounds similar to lenses. Have you looked at previous lens discussions on-list?</div></div></blockquote><div><br class=""></div><div>I had no idea what a lens is. Nor was is easy to figure out since I can’t read Scala, JavaScript, or Haskell. From what I can grok from those papers, I’m guessing it’s like C++’s pointer-to-member, but it’s more like a group of them forming an access chain from a source object to a (possibly nested) sub-object. It seems like a functional programming thing.</div><div><br class=""></div><div>From a high-level view, a poser is a kind of a lens. But the low-level details are completely different.</div><div><br class=""></div><div>* A lens is a first-class type, probably part of a Standard Library. Posers are symbolic substitution; they’re deliberately not first-class types.</div><div>* As a first-class type, lenses have data, indicating the path from source to sub-object. There is no data for a poser, since the concept is realized during translation.</div><div>* A lens, a far as I understand, targets a sub-object. A poser can target the entirety of a named object.</div><div>* A poser can cover substituting an object of one type for a layout-compatible type (including future strong type-aliases). Lenses don’t cover this use case.</div><div>* A poser’s purpose is to defeat copy-in/out semantics with reference semantics. How lenses work on copy-in/out vs. reference is unspecified.</div><div><br class=""></div><div>Swift tries to avoid direct reference semantics, and does two-way object passing as (or as-if) copy-in &amp; copy-out. This avoids having to do the pessimizations needed for safety when one object reference may alias another. Posers are limited to minimize these anti-optimizations. Posers can only be implementation aids for functions; they cannot be globals nor a property/associated-value (not the case for lenses since they’re first-class types). Posers can only alias a (sub-)block of statically determined memory (not the case for lenses either). Posers are not passed a function arguments or returns; the original object is instead.</div><div><br class=""></div><div>Something I like about the poser syntax is that we could extend it to actual lenses someday (when we can make pointer-to-member expressions).</div><div><br class=""></div><div>Oh, some previous discussions are:</div><div><br class=""></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006663.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006663.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160523/019138.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160523/019138.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005236.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/005236.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160307/012541.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160307/012541.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160627/022479.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160627/022479.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151221/004555.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151221/004555.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160801/025882.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160801/025882.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006262.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160111/006262.html</a></div><div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161212/029531.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161212/029531.html</a></div><div><br class=""></div><div>The “Lenses in Swift” video is actually at &lt;<a href="https://www.youtube.com/watch?v=ofjehH9f-CU" class="">https://www.youtube.com/watch?v=ofjehH9f-CU</a>&gt;.</div><div><br class=""></div><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">—&nbsp;</div><div class="">Daryle Walker<br class="">Mac, Internet, and Video Game Junkie<br class="">darylew AT mac DOT com&nbsp;</div><div class=""><br class=""></div></div></div></div></div></body></html>