Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Patch Available
-
Patch
Description
Apache Thrift compiler doesn't allow to use keywords in any of supported languages as field names. However, there are other compilers, like Scrooge, which do allow using some keywords as field identifiers, which leads to incompatibility.
Assume we had a service with 'delete' method, with Java code generated by Scrooge. Now we'd like to generate Python code with Apache Thrift, but encounter an error because of the 'delete' keyword.
I understand that using only Apache Thrift compiler, a user will never encounter this problem, but I think enabling keywords by request seems feasible.
Proposal
It's possible to tweak keywords on code generation stage, e.g. use 'delete_' as a name of a generated function instead of 'delete', then use the original method name for a protocol message: writeMethodBegin('delete').
This feature could be enabled with an additional flag, e.g. --screen-keywords.
I have a draft for python generator here https://github.com/nsrtvwls/thrift
The questions are, is this functionality welcome? If yes, would it require to have it supported for all languages?
Attachments
Issue Links
- relates to
-
THRIFT-2509 Uncompileable Python code due to language keywords in IDL
- Open
-
THRIFT-3290 Using from in variable names causes the generated Python code to have errors
- Closed
-
THRIFT-4655 Parser fails on the word "from"
- Closed
- links to