Variants/case classes/algebraic data types/sums/oh my!
joe.darcy at oracle.com
Sat Jun 11 19:43:24 UTC 2016
On 6/11/2016 10:44 AM, org.openjdk at io7m.com wrote:
> On 2016-06-11T12:24:06 -0400
> Brian Goetz <brian.goetz at oracle.com> wrote:
>> To amplify John's comments -- we are very interested in these topics,
>> but we believe there are some fundamentals that have to be addressed
>> first. No need to dive into great detail about how great case classes /
>> destructuring pattern matches are; we are more than aware :)
> Yes, they're a serious addiction.
>>> I believe that all of the existing languages could benefit from both
>>> JVM and Java language support for the types, and I believe that support
>>> could be provided with minimal, non-intrusive changes to the virtual
>>> machine (an extra piece of class metadata, no new bytecode
>>> instructions, a couple of extra syntax rules in the Java language that
>>> likely build upon the existing switch statement, and no new keywords).
>> By way of setting expectations .... there are no minimal, non-intrusive
>> language or JVM features. Usually, it requires a tremendous amount of
>> work to make a feature merely *seem* less intrusive; consider lambdas,
>> which are "just" function literals -- except making them work required
>> entirely overhauling type inference and method overload selection --
>> which if done right, no one notices.
> I guess I was just speaking in relative terms. I'd deem intrusive
> changes to be, for example, new bytecode instructions. The addition of
> switching on strings, I'd deem as relatively minor (although of course,
> I may be totally wrong - perhaps it was a nightmare).
FYI, switching on strings in JDK 7 was implemented entirely in javac
without any JVM changes needed:
"Project Coin: Anatomy of adding strings in switch to javac,"
More information about the valhalla-dev