Protobuf messages can recursively reference themselves to create nested
structures. It's permissible because the language allows you to reference
the type once it's been defined, including within its own definition.

I hope that helps!
- Derek

On Thu, Jul 4, 2024 at 9:13 AM Wells Cool <[email protected]> wrote:

> message DescriptorProto {
>   optional string name = 1;
>
>   repeated FieldDescriptorProto field = 2;
>   repeated FieldDescriptorProto extension = 6;
>
>   repeated DescriptorProto nested_type = 3;
>   repeated EnumDescriptorProto enum_type = 4;
>
>   message ExtensionRange {
>     optional int32 start = 1;  // Inclusive.
>     optional int32 end = 2;    // Exclusive.
>
>     optional ExtensionRangeOptions options = 3;
>   }
>   repeated ExtensionRange extension_range = 5;
>
>   repeated OneofDescriptorProto oneof_decl = 8;
>
>   optional MessageOptions options = 7;
>
>   // Range of reserved tag numbers. Reserved tag numbers may not be used by
>   // fields or extension ranges in the same message. Reserved ranges may
>   // not overlap.
>   message ReservedRange {
>     optional int32 start = 1;  // Inclusive.
>     optional int32 end = 2;    // Exclusive.
>   }
>   repeated ReservedRange reserved_range = 9;
>   // Reserved field names, which may not be used by fields in the same
> message.
>   // A given name may only be reserved once.
>   repeated string reserved_name = 10;
> }
>
> Hi! Why is it permissible to recursively define repeated DescriptorProto
> nested_type = 3; inside the message DescriptorProto?  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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/bb9da598-429d-4bfa-ac79-d4e6b7fc3b16n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/bb9da598-429d-4bfa-ac79-d4e6b7fc3b16n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CAEEMZQB_zgH8HPNhtX5uxum0E1wOF3w68U54T%3D%3DE-otjoT3dZg%40mail.gmail.com.

Reply via email to