+1 on union/intersection types.
I currently use coproducts from the shapeless library when I need this
functionality; which I guess is why I like Scala.
It can directly duplicate anything available in Kotlin or Ceylon using
nothing more than built-in features (which includes macros nowadays), or
you can go much further if you're willing to invest time into compiler
plugins.



Having said that... Intersections are obviously the sort of thing that's
going to get much more adoption if they're in the standard library or baked
into the language syntax.  As it stands, the only union available by
default is the Either type.

Improving on this is *exactly* what's happening in Dotty at the moment, the
experimental scala-next-gen compiler that was recently open sourced
(there's a good chance it'll become some future scala 3.0).
Not only will it allow you to directly specify disjoint unions, but the
entire type system is built from the ground up with the concept of
intersections and unions as a core concept, EPFL have several papers
released on the underlying theory (known as Dependent Object Types).  This
then allows intersections/unions to be automatically derived for you, such
as when you're mixing traits together:

e.g.

trait Bippy {
  def fn(s: String): String = ...
}

trait Boppy {
  def fn(i: Int): String = ...
}

class Unified extends Bippy with Boppy


Unified will now have a method with the signature:

  def fn(arg: Int or String): String

As opposed to having overloads of the fn method.



On 21 February 2014 17:26, Cédric Beust ♔ <[email protected]> wrote:

>
> On Fri, Feb 21, 2014 at 3:08 AM, Kevin Wright <[email protected]>wrote:
>
>> Of those, only Clojure and Scala run on the Java platform and are
>> relevant to this forum.
>
>
> I'd argue Kotlin and Ceylon belong there as well and also that Ceylon's
> union and intersection types provide a superior approach to the variance +
> inheritance problems that plague both Scala and Java.
>
> --
> Cédric
>

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/javaposse.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to