чт, 22 авг. 2019 г. в 23:17, Adam Cozzette <[email protected]>:

> On Thu, Aug 22, 2019 at 1:43 AM Denis Feklushkin <
> [email protected]> wrote:
>
>>
>>
>> пн, 12 авг. 2019 г. в 23:51, Adam Cozzette <[email protected]>:
>>
>>> Proto3 doesn't have a concept of field presence for singular primitive
>>> fields, so for example there is no difference between an integer field set
>>> to 0 and that same field being unset entirely.
>>>
>>
>> But in this case it will be impossible to distinguish absence of a field
>> (for example, when changing message format) from the fact that the field is
>> zero and this zero is one of legitime field value?
>>
>
> That's true, there is no way to distinguish between a field being absent
> and being explicitly set to zero.
>
>
>> Is there any explanation/rationale for this?
>>
>
> Proto3 was designed before I joined the protobuf team, but I believe the
> main rationale was to simplify implementations and in particular to enable
> an open-struct style implementation such as what Go protobuf did. The
> open-struct idea is that you can store fields in a simple struct and just
> access them directly without the need for a separate bit array indicating
> field presence.
>

Ok, thanks for the clarification, such idea sounds reasonable.


>
>
>> As a result there shouldn't be has_foo() methods for singular primitive
>>> fields, and that is how Google's protobuf libraries work with proto3. There
>>> are has_() methods for embedded message fields, though (since those are not
>>> considered primitive fields).
>>>
>>> On Sun, Aug 11, 2019 at 11:08 PM Denis Feklushkin <
>>> [email protected]> wrote:
>>>
>>>> Hello!
>>>>
>>>> There is a Protobuff 3 implementation for D:
>>>> https://github.com/dcarp/protobuf-d/
>>>>
>>>> Its author and I am diverged in the interpretation of the Proto3
>>>> documentation:
>>>>
>>>> Is it necessary to implement something like has_foo() method as in
>>>> Googles's Protobuf C++ and Dart libraries or it is violates protocol
>>>> version 3 and leaved in official libraries only for backward compatibility?
>>>>
>>>> Can someone reasonably support this or that opinion?
>>>>
>>>> Discussion beginned here:
>>>> https://github.com/dcarp/protobuf-d/issues/21
>>>>
>>>> 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/3f826c6a-c67e-4291-9b36-4922180dd7e3%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/protobuf/3f826c6a-c67e-4291-9b36-4922180dd7e3%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/CAHY2gWfwJbBmV-kZDtEf4hCDS0FvCCEyTkkQTBU3M%2B1jx2eYsw%40mail.gmail.com.

Reply via email to