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

Nate Rosenblum commented on THRIFT-1528:
----------------------------------------

I'm sympathetic to the position that "optionally set with default" is a weird 
combination of attributes for a message field. 

I think the most compelling argument in favor is protocol flexibility: making 
the field default means you don't have to program to it directly & can change 
it globally at some later date (e.g. protocol version fields), while keeping it 
optional means that you can delete the field completely in the future if you 
tire of it. Best of both worlds, I guess.

Regardless, optional-with-default is the world we live in. We should 
standardize to serializing defaulted optional fields or not. It looks like 
consensus was forming for serializing them back in March. I'm happy to 
contribute patches if we can come to agreement on this.
                
> Iconsistency in optional fields between Java/C# and python
> ----------------------------------------------------------
>
>                 Key: THRIFT-1528
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1528
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Compiler
>    Affects Versions: 0.8
>            Reporter: Stefan Gmeiner
>            Priority: Minor
>
> If a struct contains optional fields with default values the generated python 
> code serialize differently than Java or C# code.
> In Java or C# optional fields are only serialized if a field was set by the 
> client. If not the field is omited during serialization. This is possible 
> because C#/Java maintains for each field a 'isset'-boolean which records if a 
> field was set or not.
> However the generated python code does not have such a 'isset'-structure. It 
> writes every field which is not equal None. As the constructor initialize the 
> optional fields with their default value, these fields are written whether 
> they are set or not.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to