Carpet

Carpet

2M Downloads

Converting tuples to records

altrisi opened this issue ยท 2 comments

commented

Records are better than tuples in many regards, most importantly that you can name their parameters, but they can also accept primitives directly without the need of autoboxing, already implement toString, hashCode and equals out of the box, and have fully guaranteed immutability (even protected from Unsafe).

I already changed many of the tuples in Carpet in #1009, but I'll list the ones I didn't know how to call their parameters below, in case you want to change them or if at some point I understand what they do and can name them accordingly:

I didn't include the one in OptimizedExplosion because it's a MutablePair, and records are immutable.

commented

make sense! Do refactor!

commented

TIL that not only they have fully guaranteed immutability, but that their fields are even allowed for constant optimizations by the JVM (as if they were static final, source: https://github.com/openjdk/jdk/blob/51b53a821bb3cfb962f80a637f5fb8cde988975a/src/hotspot/share/ci/ciField.cpp#L239-L240).

Still don't know how to call those though.