[
https://issues.apache.org/jira/browse/THRIFT-4496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16363255#comment-16363255
]
Jens Geyer commented on THRIFT-4496:
------------------------------------
In addition to the (by intention) not exhaustive global keyword list, there are
solutions on a per language basis which make sure that proper code is generated
that compiles. They merely work as you describe, by adding underscores or using
[mechanisms like
prefixes|https://msdn.microsoft.com/en-us/library/x53a06bb(v=vs.120).aspx] and
if they don't work for a particular keyword then this is a problem that should
be fixed. And there should not be an additional switch for it, because
generating uncompileable code is a bug.
Second, the definition of "complete" is something that is hard to formalize,
because it is context dependent. So the question stays, what context you plan
to use for \{{--screen-keywords}} (and what "screen" means), i.e. who defines
what a keyword is? To my understanding keywords are defined by the language
designers, not by Scrooge.
The problem with a global, exhaustive list is furthermore, that different
languages have different ideas about what a keyword is and what not. It is hard
to explain why a particular name should be disallowed for everybody if only one
out of 20 languages has a problem with it. The list today contains often used
keywords across languages (and yes, there may be some exceptions to that rule
of thumb for historical reasons)
Personal opinion: If we start to add "fixes" in Thrift to circumvent problems
(or some vague "incompatibilities" that you mention) that other environments
introduce ... well, I'm not sure if that is such a great idea.
> Screen keywords in service method names
> ---------------------------------------
>
> Key: THRIFT-4496
> URL: https://issues.apache.org/jira/browse/THRIFT-4496
> Project: Thrift
> Issue Type: New Feature
> Components: Python - Compiler
> 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)