Hey Allen,

Also excited to hear about the Rust work! Agree with Jake, on the pain
level associated with adding type as a keyword. However, type is probably a
pretty good word to add to the keyword list if we were to add one.

Similar/Identical keywords:

- Rust, Go, Delphi, Scala:     type
- C#, ECMAScript 6    typeof
- C++    typedef, typeid, typename


Obviously some languages avoid the problem through context (like Go and
Delphi). Perhaps a reasonable approach might be to deprecate it in IDL
today, change the tests to use __type or some such and soldier on with the
Rust addition?

-Randy

On Fri, Nov 4, 2016 at 1:34 PM, Jake Farrell <[email protected]> wrote:

> Hey Allen
> Really cool to hear you are working on Rust support, know that others would
> appreciate having it available. Currently "type" is not a listed reserved
> word in the compiler/cpp/src/thrift/thriftl.ll, but due to rust using it
> that way you would have to add it to the reserved list and modify the test
> to no longer support "type" as an identifier.
>
> This would cause a lot of pain for others as "type" is a pretty commonly
> used term and would break exiting expected behavior for anyone using the
> identifier "type" in their idl today.
>
> -Jake
>
>
>
> On Fri, Nov 4, 2016 at 4:07 PM, Allen George <[email protected]>
> wrote:
>
> > Hi Jim,
> >
> > FWIW, the Thrift file I'm talking about is "TestThrift.thrift" that's
> > used as part of the cross-platform tests. And, you're right: I didn't
> > specify my language. I'm *trying* to implement Thrift support in Rust.
> > I've got part of the code-gen working, and part of the binary protocol
> > as well, but there's obviously still a lot of work to do.  "type" is
> > used to define a typedef (aka. type alias) in Rust, which means that
> > the "Bonk" struct (the first struct there) doesn't work anymore.
> >
> > Allen
> > Terminal Musings: http://www.allengeorge.com/
> > Raft in Java: https://github.com/allengeorge/libraft/
> > Twitter: https://twitter.com/allenageorge/
> >
> >
> > On Fri, Nov 4, 2016 at 12:35 PM, Jim King <[email protected]>
> wrote:
> > > The use of "type" as a field name seems suspect to me in a test thrift
> > file for the reason you described.
> > >
> > > This is similar to the use of "what" that was in some example thrift
> > files exception structures before we added what() to the C++ library,
> > breaking those examples.  Fortunately one can rename the field if using
> > BinaryProtocol because it only cares about field ordinals, not names, and
> > remain backwards compatible.
> > >
> > > Perhaps we need to update the list of reserved keywords and enforce
> them?
> > > Another possibility is to change the code generator to generate a field
> > in a structure that has a different name like "__type", however would the
> > definition of "getType()" then fail in your language?
> > >
> > > By the way, what is your target language?  You didn't specify.
> > >
> > > - Jim
> > >
> > > -----Original Message-----
> > > From: Allen George [mailto:[email protected]]
> > > Sent: Thursday, November 03, 2016 10:00 PM
> > > To: [email protected]
> > > Subject: What's the right approach to dealing with reserved words in
> > thrift structs?
> > >
> > > The struct "Bonk" (in ThriftTest.thrift) uses a reserved keyword "type"
> > in my target language. What's the right approach do dealing with reserved
> > keywords during code generation? Obviously I'd prefer that "type" wasn't
> > used at all, but...should I turn it into another name? Should I simply
> fail
> > instead?
> > >
> > > Thanks,
> > > Allen
> > >
> > > Terminal Musings: http://www.allengeorge.com/ Raft in Java:
> > https://github.com/allengeorge/libraft/
> > > Twitter: https://twitter.com/allenageorge/
> > > ------------------------------------------------------------
> > ---------------------------
> > > PRIVACY STATEMENT:
> > > This message is a PRIVATE communication.  This message and all
> > attachments are a private communication sent by SimpliVity and are
> > considered to be confidential or protected by privilege. If you are not
> the
> > intended recipient, you are hereby notified that any disclosure, copying,
> > distribution or use of the information contained in or attached to this
> > message is strictly prohibited.  Please notify the sender of the delivery
> > error by replying to this message, and then delete it from your system.
> > > ------------------------------------------------------------
> > ---------------------------
> >
>

Reply via email to