To clarify, proto3 supports extensions in that you can define custom options or create extensions for proto2 messages (since it is valid to import proto2 files). But it does not support defining an extendable message (e.g. no extension ranges can be defined with proto3).
Proto3 is almost more like a *sub*set of proto2: 1. You cannot define extension ranges in proto3 2. You cannot define required fields in proto3 3. You cannot define default values in proto3. Default values are always the zero value for a type. 4. You cannot define groups in proto3 5. Proto3 has no has* methods because, by design, an absent value is indistinguishable from its default (e.g. zero) value. 6. You cannot define an enum whose first value does not have the numeric value of zero. 7. Up until 3.5, proto3 did not preserve unrecognized fields. Even as of 3.5, this support is still not complete in all languages (such as Go), even though it is supported for proto2 (for the languages/runtimes that have proto2 support anyway). All of the "new" features ascribed to proto3 are really features of the protoc compiler, starting with v3.0, not of proto3. The new features include the following: 1. Map types 2. Streaming RPCs 3. Standard JSON representation 4. Well-known types (including Any) 5. New language-level: proto3 syntax So it's important not to conflate "protobuf v3" with bullet 5 above, "proto3". All of those other features can still be used with proto2 source files (aside, possibly, from using JSON format with a message with extensions). ---- *Josh Humphries* [email protected] On Fri, Dec 15, 2017 at 6:56 PM, 'Adam Cozzette' via Protocol Buffers < [email protected]> wrote: > Neither one is really a superset of the other. Proto3 does not support > extensions but uses the Any type as a replacement. > > On Fri, Dec 15, 2017 at 3:40 PM, ajcurtis84 <[email protected]> wrote: > >> Hello, >> >> I have not found anything in the documentation that explicitly says this. >> The only indication is that the proto3 documentation refers to proto2. >> Things like extensions are available in the proto3 syntax? >> >> thanks >> >> >> -- >> 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 [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
