2 ms·
> What you explained so far is that it doesn't play well with concurrent modification Fair enough. > I'm less interested in the philosophy of records and more
by pron 7y ago
> What you explained so far is that it doesn't play well with concurrent modification
Fair enough.
> I'm less interested in the philosophy of records and more in the use cases they support.
The use cases and motivation, as well as why mutation is wrong for records, are explained in the links I provided. Here they are again:
* https://openjdk.java.net/jeps/359 https://openjdk.java.net/jeps/359
* https://cr.openjdk.java.net/~briangoetz/amber/datum.html https://cr.openjdk.java.net/~briangoetz/amber/datum.html
- smarks 7y agoMutation without concurrency is still a problem for pattern matching. To return to your earlier example, suppose you've matched Point(3, y) and you're now in some code that assumes that the x-value of the Point is 3. Now, you call some method that has some reference to the point you're working on, and it mutates the x-value to 4. The assumption in that code after the match is now broken.
- deleted 7y ago[deleted]