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

Randy Abernethy commented on THRIFT-2464:
-----------------------------------------

This is covered pretty thoroughly in chapter 5 of the Programmer's Guide to 
Apache Thrift. I agree Thrift should supply standard cross platform types that 
work across all languages. However there are multiple layers of abstraction in 
Thrift:
 # IDL - the conceptual types
 # wire - the protocol based serialization of the types
 # language - the language specific implementation of the types

It is in #3 that the impl may need to be (or could benefit from) being tweaked. 
The IDL compiler might generate a Java TreeMap for a Thrift Map or it might 
generate a HashMap. We can not say which is the right answer without a use case.

It is also important to note that the language impl has (must have) no impact 
on the wire or conceptual type representations. Adding types to the IDL or wire 
layers is a breaking Thrift wide interface change and I think should be avoided 
unless tremendous benefit is imparted. On the other hand, changing impl types 
is by definition an implementation detail that no one on the other side of the 
RPC should care about.

In short, I agree with [~jking3] that the cpp_type and cpp_include keywords 
should be removed but the functionality should be preserved through Thrift 
annotations. So my vote is that until we have the annotations working we do not 
remove the keywords.

The annotation solution would look something like this:

{{(cpp.include = "unordered_map")}}

{{exception BadFishes {}}
{{    1: map (cpp.type "std::unordered_map<string, int16_t>") <string, i16>  
fish_errors}}
{{}}}

Should be an easy change.

 

> Transition cpp_type and cpp_include keywords to compiler annotations
> --------------------------------------------------------------------
>
>                 Key: THRIFT-2464
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2464
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.9.2
>         Environment: C++
>            Reporter: Randy Abernethy
>            Assignee: Randy Abernethy
>            Priority: Minor
>
> The cpp_type and cpp_include keywords provide a useful feature but are 
> language specific. In keeping with the trend of moving the interface language 
> to a clean cross implementation language abstraction, these two keywords 
> should be transitioned to annotations.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to