Throwing exceptions from records

Ty Young youngty1997 at gmail.com
Mon Mar 9 19:27:10 UTC 2020


On 3/8/20 4:10 AM, Kasper Nielsen wrote:
>> Right, because any and all meaningful logic is just thrown in other
>> places making them more complicated.
>>
> I took a look at one of the classes you are trying to convert to a record [1].
> And it really looks like a really poor fit for record conversion.


Why?


>   What exactly
> are you trying to accomplish? Avoid writing a single getter?


No. The point is to signify that the classes merely contain data.


>   Because something
> like equals() and toString() doesn't really make sense.


Again, why? You claim things but provide zero reasons as to why.


>   Also, by converting to
> records you would end up exposing the VarHandle which I assume is something
> you would actually want to encapsulate?


It's exposed anyway?


>   On top of that, you have a set method,
> which I find really weird given that records signal pure data carriers.


There is no "set" method, only an action, "call".


And what is a "pure data carrier" exactly? I don't see any concrete 
definition by anyone. No one said you couldn't have actions or setters 
which modify a records field's fields.


Also, why would a "pure" data carrier then need to have the ability to 
implement interfaces? It introduces problems where an interface method 
"getX()" could be different than just "x()".


> /Kasper


More information about the amber-dev mailing list