-
Notifications
You must be signed in to change notification settings - Fork 15.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is optional field officially supported in proto3? #10463
Comments
What language bindings did you find that comment in? |
cpp code, |
It is officially supported, this is probably just a typo, asking @haberman to confirm. |
We officially support proto3 optional in C++; this is a documentation bug. |
In the Proto3 language guide, all descriptions and documentation of keyword 'optional' have been removed and. all examples of 'optional' are in the context of Proto2 if any indication is given (that I can find). https://developers.google.com/protocol-buffers/docs/proto3
Oddly, I feel like there was more documentation on 'optional' a few months ago, discussing how it changed from Proto2 to Proto3, and the alternatives to use instead,. I remember reading about it, and now I can't find what I read. I thought it was in the context of "how to tell if a field has been explicitly set or if was default initialized". Could the documentation please be updated? |
Is this how Proto3 'optional' works?Going a step beyond "is it supported", I've surmised in Proto3 all values are implicitly "optional". If no value is set, then it is default-initialized in all cases. This leaves the question "is this Based on a few references, my guess is that the entire purpose of According to C++ Reference Singular Embedded Message Fields this happens (the Somewhat ironically, reading the Proto2 Optional Fields And Default Values the implication is that using Additional references: StackOverflow How to define an optional field in protobuf 3 |
There is now proper documentation for |
Hello,
After going through documentation and little bit of source code, I cannot come to a conclusion whether "optional" keyword is officially supported or not. Release notes of 3.15 shows,
Does this mean that its promoted to officially supported feature from experimental from 3.15 onwards ?
But latest code shows this, which is little confusing ( especially the comments part)
The text was updated successfully, but these errors were encountered: