You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have always been impressed with protocol buffers - there are so many nuances to the design that I appreciate as I keep using it. One that I have found especially useful is that hasX is supported on every field; even primitives. For example, I have previously written JSON <-> protobuf mappings, and this allowed me to differentiate between the "x=0" and the "x not present" case. This also maps well to databases, where x=0 and x=NULL are also different. Many/most real world systems have 0 != null, so it seems odd for protobuf to switch sides on this argument.
So can we keep hasX working as it was in proto2?
If nothing else, this is a huge behavioural change that will impede migration to proto3 (after setX(0); hasX() then returns true in proto2, false in proto3). Because it is value-dependent it will be impractical to migrate code that calls hasX() safely - e.g. static analysis will be impossible.
If that is off the table, can we at least have an option to keep the 0 != null behaviour, with the new proto3 syntax?
The text was updated successfully, but these errors were encountered:
Well there are a couple of workarounds for this if I understood well the changelog (It applies only to primitives) I did this on the fly so forgive me if there's something wrong. Both approaches are annoying anyway.
a) you can specify a null indicator like in the good ol' days.
If you need the field presence info for primitive fields, there will be "well known types" protos introduced in 3.0 beta releases, which includes built-in wrapper types. e.g.
I have always been impressed with protocol buffers - there are so many nuances to the design that I appreciate as I keep using it. One that I have found especially useful is that hasX is supported on every field; even primitives. For example, I have previously written JSON <-> protobuf mappings, and this allowed me to differentiate between the "x=0" and the "x not present" case. This also maps well to databases, where x=0 and x=NULL are also different. Many/most real world systems have 0 != null, so it seems odd for protobuf to switch sides on this argument.
So can we keep hasX working as it was in proto2?
If nothing else, this is a huge behavioural change that will impede migration to proto3 (after setX(0); hasX() then returns true in proto2, false in proto3). Because it is value-dependent it will be impractical to migrate code that calls hasX() safely - e.g. static analysis will be impossible.
If that is off the table, can we at least have an option to keep the 0 != null behaviour, with the new proto3 syntax?
The text was updated successfully, but these errors were encountered: