On Sat, Dec 10, 2016 at 11:14 PM, Matthew Zimmerman <mzimmer...@gmail.com> wrote: > Yes, it makes them smaller I agree, however shouldn't the lack of a value on > decoding be considered like a zero value was encoded? I think that is the > question here.
It's pretty much academic at this point, since we can't break backwards compatibility, but... Interpreting missing fields as implicit (overwriting) zeroes makes decoding more complicated. You have to keep track of which fields you've seen. The implementation is simpler (and quite possibly faster to do this all-at-once instead of field-by-field) for the caller, not the callee, to zero-initialize the destination value if they're re-using it. Instead of writing a plain decoder.Decode(&dst) instead, write dst = Type{} decoder.Decode(&dst) Also, if you're gob-encoding a struct with many fields (defined at compile time), but in practice few fields actually non-zero (at run time), enforcing implicit zeroes will mean many reflect calls, not few. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.