The proto compiler actually allows you to do this, but it perhaps shouldn't
as it semantically does not make sense. You don't have any guarantees that
each application is aware of the required extension; therefore you can't
really say that a message is invalid if it doesn't have that extension set.
The generated code ends up treating the extension as optional;
person.IsInitialized() does not iterate over the known extensions to search
for required extensions and verify that those are set.

On Mon, Apr 4, 2011 at 2:31 PM, Aaron Rich <aaron.r...@gmail.com> wrote:

> Newbie question:
>
> Can an extended message have a required field? For example, If I
> wanted to make any application using detailperson.proto's definition
> of a person have to have a middle name?
>
> person.proto:
> message person
> {
>  required string first_name =1;
>  required string last_name =2;
>
>  extensions 100 to 199;
> }
> -------------------------
> detailedperson.proto:
> extend person
> {
>  required string middle_name = 100;
> }
>
> Thanks.
>
> -Aaron
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to protobuf@googlegroups.com.
> To unsubscribe from this group, send email to
> protobuf+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/protobuf?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to