[ 
https://issues.apache.org/jira/browse/THRIFT-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13966644#comment-13966644
 ] 

Randy Abernethy commented on THRIFT-2429:
-----------------------------------------

Hi Ben,

I think your understanding of Thrift requiredness is incomplete. Thrift 
requiredness <> PB requiredness. Thrift has three requiredness levels:

* optional
* (normal)
* required

For example:

{code:title=req.thrift|borderStyle=solid}
struct Trade {
    1: required string       fish       //required requiredness
    2:          double       price      //normal requiredness
    3: optional i32          size       //optional requiredness
}
{code}

Normal requiredness is sometimes called default, but I avoid that in this issue 
due to possible confusion with default values.

All three of these levels behave differently. In Thrift IDL, normal 
requiredness provides the interface evolution features you associate with 
optional in PB. The optional modifier provides no additional interface 
evolution value. It simply allows you to “optimize” away the field should you 
decide not to transmit it.

A complete table of the current functionality is listed above (“-“ is used to 
represent "no qualifier", i.e. normal requiredness). The "no default" row 
describes the functionality present in Thrift today when serializing and 
deserializing all three requiredness levels.

https://issues.apache.org/jira/browse/THRIFT-2429?focusedCommentId=13957788&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13957788

Best,
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)

Reply via email to