How to deal with inconsistent objects due to mutation

I’m not sure it’s a problem, really, as long as there is a social convention that the fields of a struct are private and should not be changed or relied on, unless explicitly documented.

It’s nice that users can mess with internal types if they want, and is willing to bear the risk. It allows extension of other people’s types.

Relevant:

Edit: But yes, I agree, Julia’s approach of telling people to not mess with internal fields as opposed to forcing people by actually making them inaccessible does prioritize performance (and extensibility) over safety. I think it’s nice still.

2 Likes