On Thu, Oct 15, 2015 at 10:49 AM, Dylan Justice <dylanjust...@gmail.com>
wrote:

> 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
> "$0".
>
> 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:
https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto#L50

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#):
https://developers.google.com/protocol-buffers/docs/reference/csharp-generated#wrapper_types


>
> 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 protobuf@googlegroups.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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to