英文:
How can unknown field functionality be replicated in proto3?
问题
谷歌已经在proto3中删除了未知字段。我很想听听这个选择背后的原因。另外,如果有人知道如何复制proto2的行为,我也很想听听。
如果有关系的话,我们是用Go语言编写我们的代码。
由于proto3和grpc是并行开发的,我也想与grpc社区联系。
来源:未知字段的删除
英文:
Google has removed unknown fields in proto3. I would love to hear the reasoning behind this choice. Also, if anyone has any way to replicate the proto2 behavior I would love to hear it.
If it matters, we are writing our code in Go.
As proto3 and grpc were developed in parallel, I wanted to reach out to the grpc community as well.
Source: [Removal of unknown fields][2]
[2]: https://github.com/google/protobuf/releases/tag/v3.0.0-alpha-2 "Release Protocol Buffers v3.0.0-alpha-2 · google/protobuf"
答案1
得分: 2
去除原始类型的字段存在对于Protobuf来说在许多语言中更加“自然”和高效,因为C/C++、Java、C#和Go中的原始类型必须存在。在这些语言中,如果你想要存在信息,你可以通过将原始类型包装成指向原始类型的指针来实现。
Protobuf 3去除了原始类型的存在信息,但对于消息类型仍然保留了存在信息。因此,你可以使用相同的“包装”技术来处理Protobuf。Protobuf现在有包装原始类型的标准消息。
英文:
Getting rid of field presence for primitives makes Protobuf more "natural" and efficient in many languages, since primitives in C/C++, Java, C#, and Go must be present. In such languages, if you want presence information you "box" the primitive by making it a pointer to a primitive.
Protobuf 3 gets rid of presence for primitives but still has it for messages. Thus, you can use the same "boxing" technique for Protobuf. Protobuf now has standard messages that box primitives.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论