Why were structural records removed?


#1

this says that they were removed because you couldn’t impl anything on them doesn’t that also apply to tuples? Tuples are still in the language


#2

They had three usability problems:

  1. The fields had to be in the exact same order every time you constructed an instance of the record. This is because the compiler needed a canonical ordering.

  2. They could not be recursive without the compiler doing fancy typechecking (coinductive IIRC), which was felt to be not worth the effort.

  3. Field-level privacy can’t work with them.


[Pre-RFC]: Unnamed struct types
#3

In regards to 1 above, can’t the compiler just automatically rearrange the fields in an alphabetical order internally? In regards to 3, doesn’t the same apply to tuples?


#4

At the time the decision was made, all structs were essentially #[repr(C)] implicitly: i.e. the compiler was not permitted to reorder the fields.

I think that structural records are still not worth their weight.