Re: Zero enums

2008-10-27 Thread Kenton Varda
Added to my todo list. On Sat, Oct 25, 2008 at 1:19 AM, Marc Gravell [EMAIL PROTECTED]wrote: Ah! Right. That makes more sense. Could that perhaps be added to the language guide Optional Fields And Default Values? Marc --~--~-~--~~~---~--~~ You received

Re: Zero enums

2008-10-25 Thread Marc Gravell
Ah! Right. That makes more sense. Could that perhaps be added to the language guide Optional Fields And Default Values? Marc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this

Zero enums

2008-10-24 Thread Marc Gravell
and FieldDescriptorProto.Type. So: * have I doe something wrong (i.e. I shouldn't be seeing these zeros)? or * should protobuf-net accept zero enums even if no such enum is defined? or * is the descriptor.proto lacking some zeros that should be there? (if I add the missing zero enum values it works fine and I can

Re: Zero enums

2008-10-24 Thread Marc Gravell
I might have found the answer... if you try to provide a different value, the parser will treat it like an unknown field (from the language guide). So this means that enums are essentially unchecked: invalid values are silently ignored? Marc --~--~-~--~~~---~--~~

Re: Zero enums

2008-10-24 Thread Marc Gravell
More: actually, the problem wasn't in the file - it was in the defaults... for example: enum Label { // 0 is reserved for errors LABEL_OPTIONAL = 1; LABEL_REQUIRED = 2; LABEL_REPEATED = 3; // TODO(sanjay): Should we add LABEL_MAP? }; ... optional Label

Re: Zero enums

2008-10-24 Thread Kenton Varda
The reasoning for unknown enums being treated as unknown fields goes something like this: We cannot simply use an unknown numeric value since many languages do not allow enum types to represent numeric values other than the set of values explicitly defined for them. Furthermore, even if they did,

Re: Zero enums

2008-10-24 Thread Marc Gravell
Makes sense - it just seems a little odd that the optional enums don't have a valid default... Marc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to

Re: Zero enums

2008-10-24 Thread Kenton Varda
Oh, the implicit default for enums is the first defined value, not zero. On Fri, Oct 24, 2008 at 3:03 PM, Marc Gravell [EMAIL PROTECTED]wrote: Makes sense - it just seems a little odd that the optional enums don't have a valid default... Marc