4 ms·
> It’s impossible to differentiate a field that was missing in a protobuffer from one that was assigned to the default value. Presumably this decision is in pla
by humbledrone 7y ago
> It’s impossible to differentiate a field that was missing in a protobuffer from one that was assigned to the default value. Presumably this decision is in place in order to allow for an optimization of not needing to send default scalar values over the wire.
Isn't this just flat incorrect? You can tell the difference between set-to-default and not-set with buffer.has_some_field().
- ronnier 7y agoNot for things like ints and strings.
- kentonv 7y agoIt depends on which version you're using. In proto1 and proto2, every field had a "has" method and "explicitly set to default value" was different from "absent". In proto3, they tried to remove this feature, and instead said that for basic types, "set to default" and "absent" are the same thing. (I wrote proto2. I left Google before proto3 came about.)
- humbledrone 7y agoThanks. I must be only used to proto2.