Data classes
Mark Raynsford
mark at io7m.com
Thu Nov 2 10:46:50 UTC 2017
On 2017-11-01T14:53:40 -0400
Brian Goetz <brian.goetz at oracle.com> wrote:
> 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.
This looks great!
One thing springs to mind with the accessors: Is it possible that the
generated accessor methods could participate in the implementation of
interfaces? For example:
interface Vector
{
double x();
double y();
double z();
}
__data class Vector3 (double x, double y, double z)
implements Vector { }
The Vector3 type would automatically get x(), y(), and z() methods
based on the field declarations. This may imply, of course, that the
fields are public by default.
I don't see any obvious reasons why this couldn't work, but you've
almost certainly thought further than I have on the subject.
--
Mark Raynsford | http://www.io7m.com
More information about the amber-spec-experts
mailing list