Data classes

Zheka Kozlov orionllmain at gmail.com
Thu Nov 2 14:44:15 UTC 2017


Also, it would be interesting to know how to model closed data class
hierarchies (like sealed in Scala). I suppose it should be something like
that:

__data class ASTNode {
    ASTNode() {} // make constructor package-private so no one outside can
inherit
}

__data class ASTNumber(double num) extends AST { }
__data class ASTBinaryOperator(char op) extends AST { }
...


2017-11-02 21:29 GMT+07:00 Zheka Kozlov <orionllmain at gmail.com>:

> Hi Brian.
>
> I'm happy to see this proposal. This is very similar to how I imagined
> data classes in Java. Just one thing that looks a bit ugly to me is the
> empty curly braces after the data class declaration. Can we omit them? Most
> of data classes will have no members, so the redundant curly braces will
> clutter the code.
>
>
> 2017-11-02 1:53 GMT+07:00 Brian Goetz <brian.goetz at oracle.com>:
>
>> At the following URL, please find a writeup containing our current
>> thoughts on Data Classes for Java:
>>
>>     http://cr.openjdk.java.net/~briangoetz/amber/datum.html
>>
>> Comments welcome!
>>
>> We'll be making a prototype available soon for folks to play with.
>>
>
>


More information about the amber-spec-observers mailing list