thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4496) Dealing with language keywords in Thrift (e.g. service method names)
Date Thu, 12 Jul 2018 16:40:00 GMT

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

Jens Geyer commented on THRIFT-4496:
------------------------------------

{quote} Cross test?{quote} 

I think a cross test does not make much sense, because once the code compiles, next to everything
goes across the wire numerically encoded. There are not struct field names or argument names,
only numeric IDs. Only exception to that rule is the service name which is sent as string.
Hence, the name of any field in a particular language does only matter to that language. So
the real test here will usually be: Does it compile?

{quote} Right way to test it automatically? {quote} 

There are some implementations of tests in some of the lib/lang/test folders. I personally
added one for C# and for Delphi, but neither one is run in an automated manner. Nevertheless,
adding them to the automatically executed tests where possible sounds good to me. In theory
it should be enough to have one file per /test/lang folder added to the build with some lang-specific
keywords etc in it.

There is also /test/NameConflictTest.thrift, which today is not fully working for some languages,
but I spent quite some time to carefully handcraft all the test cases in that file. It's not
exhaustive, though, and probably a bit biased towards what languages I work with. I would
love to see that one added as automated test case, but that's probably way out of scope here.

 

 

 

 

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

Mime
View raw message