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

Marcin Zieleń commented on THRIFT-627:
--------------------------------------

Why setter __set_field() modifies the __isset.field to true ONLY for optional 
fields?

This code behaves differently if field is optional or required.

response.__set_field(7);
cerr << response.__isset.field << endl;

If field is required response.__isset.field is still false.

After transmitting response to receiver it's .__isset.field is true.

                
> should c++ have setters for optional fields?
> --------------------------------------------
>
>                 Key: THRIFT-627
>                 URL: https://issues.apache.org/jira/browse/THRIFT-627
>             Project: Thrift
>          Issue Type: Improvement
>          Components: C++ - Compiler
>         Environment: c++
>            Reporter: Ben Taitelbaum
>            Assignee: Jake Farrell
>             Fix For: 0.7
>
>         Attachments: thrift-627_0.5.x.patch, thrift-627-no-cap-name.patch, 
> thrift-627.patch, thrift-627.patch, thrift-627_trunk.patch
>
>
> It seems non-intuitive to me to have to set __isset.someField = true after 
> setting an optional field someField on a struct. Would it make sense to have 
> a set_someField method that would both set the field and modify __isset?
> One of the cases for this is for when a field goes from being required to 
> being optional, and it's easy to forget to set __isset in the code.

--
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