On Thu, Oct 15, 2015 at 10:49 AM, Dylan Justice <dylanjust...@gmail.com>
> I'm really missing the has_foo() functions on primitive elements. Was the
> decision to drop it from proto3 based on a survey of code on github, or
> just on an anecdotal type sentiment that "nobody's using it"?
The decision was made based on years of working experience on Google's huge
code base with billions lines of code and more than 100,000 .proto files.
It's believed to be the right thing to do by some of the most senior
engineers in Google.
> Here's my anecdote, for the record: I've started switching from Proto2 to
> Proto3. I'm converting an application with a Java server and several
> clients in Java and C#. One is .NET CF 3.5, which has no support beyond
> proto2. The application sends a lot of complex messages back and forth,
> several of which have currency values. There is a big difference in the
> business logic between a message with a currency value of "not set" and
> The only alternatives I'm seeing to support this protocol with proto3 are
> to either (a) change each currency amount into a submessage, to (b) pair
> each primitive with a boolean "isSet" flag, or (c) back out and stick with
> proto2. I'm leaning towards (c), the others seem like more work to
> implement, and more annoying to maintain.
For (a), you can use the wrapper types we added in proto3:
That's the recommended way to implement has function in proto3. In some
languages (C# is one example), these wrapper types will be translated to
built-in nullable types. See (for C#):
> Anyhow, I understand that the optional / has_foo() functionality would add
> a lot of complexity to the tool for several platforms, but would really
> simplify the user code, and just generally strikes me as being a critical
> functionality for a large family of messaging protocols.
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+unsubscr...@googlegroups.com.
> To post to this group, send email to email@example.com.
> Visit this group at http://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
To post to this group, send email to firstname.lastname@example.org.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.