<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 20, 2017, at 6:59 PM, Howard Lovatt <<a href="mailto:howard.lovatt@gmail.com" class="">howard.lovatt@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">There is a *bug* that the Swift people know about, but you are **meant** to be able to do this:</div></div></blockquote><div><br class=""></div><div>Is there a plan to fix this?</div><div>If it worked properly this would be quite wonderful.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class="">ModuleA<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">A.swift</blockquote><span class="gmail-m_8276977146152905134gmail-im"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public protocol P {</blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func m() -> String</blockquote></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">}<br class=""></blockquote></blockquote></span><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">extension Int: P {</blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public func m() -> String { <span style="font-size:12.8px" class="">return "AP.m" </span><span style="font-size:12.8px" class="">}</span></blockquote></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">}<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote>ModuleB<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote>B.swift<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><span class="gmail-m_8276977146152905134gmail-im">public protocol P {<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func m() -> String</blockquote>}<br class=""></span>extension Int: P {<blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">public func m() -> String { <span style="font-size:12.8px" class="">return "BP.m" </span><span style="font-size:12.8px" class="">}</span></blockquote>}<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class="">ModuleC<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">A.swift</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">import ModuleA</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func am(_ i: Int) -> String { return i.m() }<br class=""></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">B.swift<br class=""></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">import ModuleB</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">func bm(_ i: Int) -> String { return i.m() }<br class=""></blockquote></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">main.swift<br class=""></blockquote></blockquote><blockquote style="font-size:12.8px;margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote></blockquote>let i = 0<br class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class=""></blockquote></blockquote>print(am(i))<br class="">print(bm(i))</blockquote></blockquote></blockquote></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature"> -- Howard.<br class=""></div></div>
<br class=""><div class="gmail_quote">On 21 June 2017 at 00:02, David Baraff via swift-users <span dir="ltr" class=""><<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">I posted this on Apple’s developer forums, and someone suggested trying this here.<div class="">Basically, see <a href="https://forums.developer.apple.com/thread/80349" target="_blank" class="">https://forums.developer.<wbr class="">apple.com/thread/80349</a></div><div class=""><br class=""></div><div class="">but in a nutshell: consider that a widely used class/struct (such as CGPoint) is missing some “obvious” functionality [don’t debate that part, just go with it for now], such as the ability to scale a point by a scalar using * as an operator: so in my awesome library “GeometryBase” I write</div><div class=""><br class=""></div><div class=""> public func * (left: CGPoint, right: double) -> CGPoint {</div> return CGPoint(x: right*left.x, y: right*left.y)<br class=""> }<div class=""><br class=""></div><div class="">Why public? Well, of course, because I want to use library GeometryBase in many apps or other libraries, and now this overload exists in only one place.</div><div class=""><br class=""></div><div class="">But other bright people have the same idea, and now I want to use their libraries. (some of them in my company, some of them not.)</div><div class=""><br class=""></div><div class="">And now we’re stuck, because everyone is trying to make up for the same (perceived) lack and everyone wants them public so that they don’t have to keep sticking them in each library they write.</div><div class=""><br class=""></div><div class="">This is not a made up situation: many people even within one company trying to share code somewhat informally are going to write the same code to make using CGPoint/Size/Rect easier, and now we can’t share anything safely.</div><div class=""><br class=""></div><div class="">Anybody got some good ideas what to do about this?</div><div class=""><br class=""></div><div class="">[Same question could apply to adding extensions.]</div><div class=""><br class=""></div></div><br class="">______________________________<wbr class="">_________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-users</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>