Intersection and Union Types for Java

Suminda Sirinath Salpitikorala Dharmasena sirinath1978m at gmail.com
Thu Jan 21 04:32:56 UTC 2021


Maybe this can be given to a university as a research project. Perhaps
Rice? When they come up with something tangible it can be added to Java.
May not cost as much as doing it in house.

On Wed, 20 Jan 2021 at 20:07, Brian Goetz <brian.goetz at oracle.com> wrote:

> It surely *can*; evidence is here:
> https://scholarship.rice.edu/handle/1911/103594
>
> The real question (and this is always the case) is whether we should.  As
> you point out, there is clearly a nonzero benefit.  But doing so is a
> complex endeavor, full of tradeoffs.  Spending the at-least-a-thousand
> expert-hours on this, means that effort is not available to do something
> else, whose benefit might be dramatically more.  And we have a limited
> budget for asking users to absorb new language complexity; this may not be
> the best place to spend that.
>
> So yes, it could, but it's been a deliberate choice not to, because there
> are other places we can better expend that effort.
>
> On 1/20/2021 1:53 AM, Suminda Sirinath Salpitikorala Dharmasena wrote:
>
> Hello,
>
> Can the Java type system be extended to accommodate Intersection and Union
> Types.
>
> Currently we can write:
>    <T extends A & B> void f(T t) { ... }
>
> but not
>
>    <T extends A | B> void f(T t) { ... }
>
> or
>
>    <T extends (A | B) & C> void f(T t) { ... }
>
> Also we cannot have
>
>    void f(A & B t) { ... }
>
> or
>
>    void f((A | B) & C t) { ... }
>
> When considering languages like Ceylon (https://ceylon-lang.org/) and
> Scala 3 / Dotty (https://dotty.epfl.ch/) these seem to be very useful.
>
> Suminda
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210121/e4d5f4e3/attachment-0001.htm>


More information about the compiler-dev mailing list