You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/07/05 04:05:00 UTC

[jira] [Commented] (THRIFT-4496) Dealing with language keywords in Thrift (e.g. service method names)

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

ASF GitHub Bot commented on THRIFT-4496:
----------------------------------------

nsrtvwls commented on issue #1567: THRIFT-4496: python specific list of keywords for python generator
URL: https://github.com/apache/thrift/pull/1567#issuecomment-402600811
 
 
   1. I can remove python keywords not used by other supported languages from the global list. It seems a bit risky though.
   
   2. I really can't see a problem here. With this change the behavior for all generators (except for py) is exactly the same as before: a keyword from the global list causes a failure. As soon as generator learns to make valid ids from keywords, it overrides the validate_input method with no-op or even implements a context dependent validation.
   
   3. I can see your concern here. Speaking of py generator, I haven't found any logic for built-ins, so maybe it's better to start from keywords first. As I've said before, a generator can implement these complex checks in their validate_input methods.
   
   I couldn't find a way to make it easy for all generators to generate valid code from a source with a keyword. There are cases when the original id is needed to suppport protocol and there are cases when the id should be tweaked to make code compileable. It seems like there is no way around going through the code and changing a half of id occurences. After it's done, switching off failures on keywords seems pretty easy.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Dealing with language keywords in Thrift (e.g. service method names)
> --------------------------------------------------------------------
>
>                 Key: THRIFT-4496
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4496
>             Project: Thrift
>          Issue Type: New Feature
>          Components: Compiler (General)
>            Reporter: Vera Filippova
>            Priority: Minor
>
> 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.
> h1. 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?



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