<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div><br>On Nov 11, 2017, at 9:44 AM, John Holdsworth <<a href="mailto:mac@johnholdsworth.com">mac@johnholdsworth.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class="">Isn’t there a third way? I wrote a bridge between Swift and Java without having to</div><div class="">change the compiler at all by using a code generator to generate bridging Swift</div><div class="">rather than having a Java importer.</div></div></blockquote><div><br></div><div>Good point. For unidirectional importing without deep support for overriding or runtime integration like what we do with ObjC, which AIUI is the extent of Chris's ambition with Python interfacing here, a code generator can get the job done without requiring deep compiler integration, though at the expense of needing an added tool in your build process. Have you looked at all into making SwiftJava integrate with the package manager or with Xcode yet? How's that experience?</div><div><br></div><div>-Joe</div><br><blockquote type="cite"><div><div class="">The script introspects the classes/packages</div><div class="">you’re interested in using a script and generates code such as the following:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0); background-color: rgb(255, 255, 255);"><span class="" style="color: rgb(0, 0, 0);"> </span>/// public java.lang.String java.lang.Object.toString()</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">private</span> <span class="" style="color: rgb(186, 45, 162);">static</span> <span class="" style="color: rgb(186, 45, 162);">var</span> toString_MethodID_9: <span class="" style="color: rgb(112, 61, 170);">jmethodID</span>?</div><div class="" style="margin: 0px; line-height: normal; background-color: rgb(255, 255, 255); min-height: 14px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">open</span> <span class="" style="color: rgb(186, 45, 162);">func</span> toString() -> <span class="" style="color: rgb(112, 61, 170);">String</span>! {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">var</span> __locals = [jobject]()</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">var</span> __args = [jvalue]( repeating: jvalue(), count: <span class="" style="color: rgb(39, 42, 216);">1</span> )</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">let</span> __return = JNIMethod.CallObjectMethod( object: javaObject, methodName: <span class="" style="color: rgb(209, 47, 27);">"toString"</span>, methodSig: <span class="" style="color: rgb(209, 47, 27);">"()Ljava/lang/String;"</span>, methodCache: &JavaObject.toString_MethodID_9, args: &__args, locals: &__locals )</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">defer</span> { JNI.DeleteLocalRef( __return ) }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> <span class="" style="color: rgb(186, 45, 162);">return</span> __return != <span class="" style="color: rgb(186, 45, 162);">nil</span> ? String( javaObject: __return ) : <span class="" style="color: rgb(186, 45, 162);">nil</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"> }</div></div><div class=""><br class=""></div><div class="">This bridging code, along with some supporting classes is compiled conventionally</div><div class="">along with your app. See:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/SwiftJava/SwiftJava" class="">https://github.com/SwiftJava/SwiftJava</a></div><div class=""><a href="https://github.com/SwiftJava/java_swift/blob/3a48760a5528ccb31d998afbfcb09d291268674f/Sources/JavaObject.swift" class="">https://github.com/SwiftJava/java_swift/blob/master/Sources/JavaObject.swift</a></div><div class=""><a href="https://github.com/SwiftJava/SwiftJava/blob/master/src/genswift.java" class="">https://github.com/SwiftJava/SwiftJava/blob/master/src/genswift.java</a></div><div class=""><br class=""></div><div class="">Python’s introspection seems to be reasonably capable and could certainly support</div><div class="">this approach. You’d need some sort of omni-type enum for the arguments and return.</div><div class=""><br class=""></div><div class=""><a href="https://stackoverflow.com/questions/196960/can-you-list-the-keyword-arguments-a-python-function-receives" class="">https://stackoverflow.com/questions/196960/can-you-list-the-keyword-arguments-a-python-function-receives</a></div><div class=""><a href="https://docs.python.org/2/c-api/intro.html" class="">https://docs.python.org/2/c-api/intro.html</a></div><div class=""><br class=""></div><div class="">John</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 11 Nov 2017, at 16:13, David Hart 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=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On 11 Nov 2017, at 16:02, Joe Groff 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" style="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;" class=""><div class=""><div class=""></div><div class=""><br class=""></div><div class=""><br class="">On Nov 10, 2017, at 8:35 PM, Chris Lattner 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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 10, 2017, at 6:12 PM, Slava Pestov 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=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Nov 10, 2017, at 6:10 PM, 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=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Setting this aside, I’m very curious to hear whether type providers influence your thinking after you’ve had a chance to look into them. I have always thought they were very cool.</span></div></blockquote></div><br class=""><div class="">I’m in favor of solving this problem with something like type providers also. The required compiler changes would be significant but would also clean up the interface between the ClangImporter, Sema and Serialization. If done right it would be a net gain that would benefit all users, instead of just adding YetAnotherCornerCase™ that makes implementation maintainers curse and scream.</div></div></div></blockquote><br class=""></div><div class="">I find it ironic that you’re talking pejoratively about a feature that has very narrow impact, complaining about how much of an impact on the compiler it would have, and then pine for a hugely invasive feature - one that would cause a ton of code churn, and probably wouldn’t actually be enough to eliminate the special cases in place because of ObjC interop.</div></div></blockquote><div class=""><br class=""></div><div class="">You underestimate the impact this would have on function call type checking, but since this is an additive, non-ABI-stability feature, I have trouble considering it a candidate for Swift 5, so I don't think there's a time constraint forcing us to consider the "narrow" vs "huge" dimension. What's the best thing for the language and tools in the long term? This is a feature that influences the semantics of potentially any call site in all Swift code, which we'd have to live with forever if we accepted it now. Opening up the compiler architecture to make custom importers easier to write is a great solution to a ton of problems, including yours I think, without adding complexity to the core language. Experience in .NET land seems to show it's a great technique for integrating dynamic systems with static type systems, without poking unnecessary holes in the static language's type system</div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I agree with Joe. I also think that it would be very important to compare both approaches in detail before choosing one, because the last thing we want is to end up with both in the language. And if this proposal is accepted, we might refrain from introducing custom importers later, even if they are the better long term solution.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I want Swift to continue to shine for a very long time because I enjoy this language and I just want to make sure we don’t jeopardize that by choosing a quick solution without taking in consideration other solutions.</div><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="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;" class=""><div class=""><div class="">-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><div class="">-Chris</div><div class=""><br class=""></div><br class=""></div></blockquote><blockquote type="cite" class=""><div 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></div></blockquote><blockquote type="cite" style="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;" class=""><div 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><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="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;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="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;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></blockquote></body></html>