Re: Who's HOFs on first?
Michael Bayne <[email protected]> Wed, 11 Nov 2015 08:14:01 -0800
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAOqP6L0SWF8jDnO6yi4PAs1+68YqJzTta-urFfraOCy1Cu1=Bg@mail.gmail.com> |
On Wed, Nov 11, 2015 at 5:36 AM, Naftoli Gugenheim <[email protected]> wrote: > https://github.com/ReactiveX/RxJava had to solve this, you may want to > investigate their approach. I assume you mean by "solve this" the existence of the RxScala library which completely duplicates and wraps the RxJava library, providing an API based on Scala's function types with proper variance annotations. That's a very engineering intensive solution. I'd like to avoid maintaining two complete copies of my API if possible. This is a good reminder of one of the pain points of Java/Scala/Kotlin interop, which is variance. If I use Java's function types, they are invariant, which means I have to sprinkle existentials everywhere, but if I use Scala's function types, Java sees the use sites as invariant, so I end up needing to add existentials anyway. I suppose there's no avoiding that particular lowest common denominator if one wants to support Java. Plus Kotlin doesn't understand Scala's variance annotations and vice versa, so for Kotlin/Scala interop, one requires use site declarations as well. At least if I'm using Java's function types, I won't accidentally forget the variance annotations because things "just work" from Scala, but then don't work when used from another language. It keeps me honest. -- [email protected] -- You received this message because you are subscribed to the Google Groups "scala-language" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.