4 ms·
> Now, I have to check each field individually, in manually written code, to verify that no required fields are missing. You always had to check the individual
by madgar 10y ago
> Now, I have to check each field individually, in manually written code, to verify that no required fields are missing.
You always had to check the individual fields for the zero value. A required field in a proto2 message can be set but also have the default value and pass initialization.
- cbsmith 10y agoI think you wording is a bit difficult to parse. Does this convert what you are trying to say: In proto2, default values are for optional fields. The value of an optional field would be that value, but there's a separate concern as to whether that field had been set.
- teacup50 10y ago> You always had to check the individual fields for the zero value. No, you didn't. A required field has a value, period. If it defaults to a particular value, then that's the value it has. If you had a non-required field, then you marked it 'optional', and checked for the field's existence (or mapped optional fields to a Maybe/Option monad representation, forcing the issue).