Data classes

Zheka Kozlov orionllmain at
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

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

__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>:

> 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>:
>> At the following URL, please find a writeup containing our current
>> thoughts on Data Classes for Java:
>> Comments welcome!
>> We'll be making a prototype available soon for folks to play with.

More information about the amber-spec-observers mailing list