Why were structural records removed?

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

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.

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?

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.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.