I was thinking a little bit about the potentially hairy situation of trying to deserialize a struct that has optional fields with default values. The problem that could happen is that the optional field is omitted from the serialized data, but once you're done reading, you find your struct has a value for that field. I guess some people might appreciate this situation, but personally, I think it would lead to weird inconsistencies.

However, if we made the compiler throw errors when you try to assign a default value to an optional field, then this problem could never happen. Required fields would have to be present from the get go or you'd get serialization errors, so there's no risk of running into this problem.

What does everyone think about this option?

-Bryan

Reply via email to