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

Aleksey Pesternikov commented on THRIFT-2429:
---------------------------------------------

[~codesf],
{quote}
This is the mirror image of what = defaults do to optional today. An optional 
field with a default value is no longer semantically optional. This is a more 
serious transgression in my mind but we have lived with it since inception. 
{quote}
Exactly. this *is* the problem that need to be fixed. If this problem is fixed, 
your goal of providing option to not write default values would be achieved.
{quote}
Optional fields with default values will always be present on the read side 
with the default value at minimum (and usually transmitted).
So the goal here is to give all camps what they need and to do it in a 
consistent and easy to explain way. You can:
never use defaults
use defaults that always serialize (=)
use defaults that typically don't serialize (=?)
{quote}
I'm sorry, I don't see how introducing =? is consistent and easy to explain. 
Instead of fixing "optional with default" inconsistency, it introduce even more 
inconsistency by making required and normal field behaving like optional.

Providing "optional with default" changed to not send default, your goal is 
achievable without creating Occam's =?
never use defaults: optional without default (same as before)
use defaults that always serialize: normal (AKA opt-in-req-out) with = default. 
use defaults that typically don't serialize: *optional with = default*



> 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