[ https://issues.apache.org/jira/browse/THRIFT-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13960534#comment-13960534 ]
Randy Abernethy commented on THRIFT-2429: ----------------------------------------- Hey Dave, I think you're right we don't need the annotations. Here's the IDL and semantic under consideration: {code} struct x { 1: optional i32 y = 5 } {code} * The optional modifier says: only serialize if set * The default value says: never serialize if set to 5 The reader will set y to 5 and then read the stream, overwriting the 5 if a value for y is provided by the stream. So the reader will always see some value set for y at the end of the deserialization. We are essentially giving the combination of optional requiredness and a default value a clearly defined meaning in IDL across all languages. The result is the interface optimization desired, the ability to elide default values directly in Apache Thrift IDL. -Randy > Provide option to not write default values, rely on receiver default > construction instead > ----------------------------------------------------------------------------------------- > > Key: THRIFT-2429 > URL: https://issues.apache.org/jira/browse/THRIFT-2429 > Project: Thrift > Issue Type: Improvement > Components: C++ - Compiler > Affects Versions: 0.9.1 > Reporter: Chris Stylianou > Assignee: Randy Abernethy > Labels: default, optional, required > > Would there be any objections to a patch that does not write default values > (essentially the same logic as the optional attributes). This obviously > relies on the receiving application using the same IDL version to ensure the > defaults used on object construction match the senders. -- This message was sent by Atlassian JIRA (v6.2#6252)