<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=""><div class="">Is this operator common in other languages? I would actually expect that the conversation is not 'almost-implicit' but completely implicit instead. I think both - a prefix and postfix operator - are not obvious enough what happens here,&nbsp;especially because this kind of conversion is not happening in other parts of the language.<div class="">All conversions are implicit (from explicit type to protocol, from Swift stdlib types to Objective-C types, from any type to Any, …) currently.</div><div class=""><br class=""></div><div class=""><div class="signature">______________________<br class=""></div><div class="signature"><br class=""></div><div class="signature">Benjamin Herzog</div></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;"><br class=""></div></div><div><blockquote type="cite" class=""><div class="">On 8. Jul 2017, at 22:10, Hooman Mehr 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="">I like this promote operator idea. I have been defining similar operators for specific projects almost at random. It makes sense to come up with a well-defined behavior and name for such operators, as a common practice as you suggest.<div class=""><br class=""></div><div class="">The problem with the postfix operator is that it does not currently work without an extra set of parenthesis:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162); background-color: rgb(255, 255, 255);" class="">postfix<span style="" class=""> </span>operator<span style="" class=""> ^</span></div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">postfix</span> <span style="color: #ba2da2" class="">func</span> ^&lt;T,U&gt;(lhs: <span style="color: #703daa" class="">KeyPath</span>&lt;<span style="color: #4f8187" class="">T</span>,<span style="color: #4f8187" class="">U</span>&gt;) -&gt; (<span style="color: #4f8187" class="">T</span>)-&gt;<span style="color: #4f8187" class="">U</span> { <span style="color: #ba2da2" class="">return</span> { $0[keyPath: lhs] } }</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">struct</span> Guy { <span style="color: #ba2da2" class="">let</span> name: <span style="color: #703daa" class="">String</span> }</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #ba2da2" class="">let</span> guys = [</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #4f8187" class="">Guy</span>(name: <span style="color: #d12f1b" class="">"Benjamin"</span>),</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #4f8187" class="">Guy</span>(name: <span style="color: #d12f1b" class="">"Dave"</span>),</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #4f8187" class="">Guy</span>(name: <span style="color: #d12f1b" class="">"Brent"</span>),</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; <span style="color: #4f8187" class="">Guy</span>(name: <span style="color: #d12f1b" class="">"Max"</span>)</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">]</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);" class=""><span style="color: #4f8187" class="">guys</span><span style="" class="">.map(\.name</span><span style="text-decoration: underline;" class="">^</span><span style="" class="">) </span>// Error: Invalid component of Swift key path</div><div style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class=""><span style="color: #4f8187" class="">guys</span>.<span style="color: #3e1e81" class="">map</span>((\.name)^) <span style="color: #008400" class="">// This works</span></div></div><div class=""><span style="color: #008400" class=""><br class=""></span></div><div class="">Is this a bug?&nbsp;</div><div class=""><br class=""></div><div class="">That is the reason I used a prefix operator (~) in my suggestion in the a previous e-mail on this thread.</div></div></div></blockquote></div><br class=""></body></html>