I don't pretend to know the original thinking, but it would be very hard to add 
such now without breaking existing clients. However, note that if you *really* 
don't want to have to get the lengths, you could encode your data inside a 
"group", since this has a terminator rather than a length prefix. Treat the 
data as a "repeated" set of the group, and job done.

Of course, writing the length isn't usually a massive task either, but *not* 
writing it is easier :p

Caveat: technically groups are semi-deprecated, giving preference to 
length-prefixed messages. I believe that part of the reasoning here is the 
higher cost of reading *unexpected* groups since you must parse the stream 
rather than just copy (or skip) the next [n] bytes, but in my *own* use of 
protobuf this is rarely an issue: in the majority of cases all my clients know 
about the fields. There is also a difference in the size, but "difference" is 
the key term here - neither approach is always longer or always shorter; any 
comparison depends on both the field number and the size of the data.

I openly confess to having a strong like for "groups" - they do make the 
encoding process simpler :p

Marc

On 7 Jul 2011, at 14:18, nicolas hofmann <hofmann....@gmail.com> wrote:

> My question is simple but i didn't found the answer anywhere. I was
> wondering why the tag number range started at one and not zero.
> 
> I was looking for a way to stream multiple messages without having to
> compute their sizes and realized that just add a zero tag number at
> the end could be a good way to mean the end of the current message
> since it's illegal. I searched here and in the
> documentation(especially in the encoding section) but saw no good
> reason to this limitation.
> 
> It look so simple i think I'm probably missing something but, by
> definition, i don't know what.
> 
> 
> Thanks,...
> 
> -- 
> 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