You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Andrew Pennebaker <ap...@42six.com> on 2013/09/11 16:58:28 UTC

Reducing namespace boilerplate?

If I want my .thrift to be compatible with C++ and Java, I think I have to
write both:

namespace cpp com.blah.blah

and:

namespace java com.blah.blah

Which seems redundant when the namespaces are the same. I'd much rather
write something like:

namespace com.blah.blah

And just let all languages use the same namespace scheme. But thrift 0.9.0
doesn't seem to support this, throwing an empty compile error about syntax.

Is there a way to do this in current Thrift? Are there plans in the future
to support the syntax I'm after?

Re: Reducing namespace boilerplate?

Posted by Ben Craig <be...@apache.org>.
This may be getting pedantic, but that page reads more like a 
specification of thrift IDL.  BNF is great for specifications, but it 
reads poorly for documentation.

So technically, there is something on the website that answers this 
question, it just doesn't answer it in a friendly way.



From:   "Jens Geyer" <je...@hotmail.com>
To:     "Thrift Users" <us...@thrift.apache.org>, 
Date:   09/11/2013 02:27 PM
Subject:        Re: Reducing namespace boilerplate?



> I just wish this were documented better.

You mean, even better documented as here?
http://thrift.apache.org/docs/idl/
Namespace
A namespace declares which namespaces/package/module/etc. the type 
definitions in this file will be declared in for the target languages. The 


namespace scope indicates which language the namespace applies to; a scope 


of '*' indicates that the namespace applies to all target languages.

[5]  Namespace       ::=  ( 'namespace' ( NamespaceScope Identifier ) |
                                        ( 'smalltalk.category' 
STIdentifier ) |
                                        ( 'smalltalk.prefix' Identifier ) 
) 
|
                          ( 'php_namespace' Literal ) |
                          ( 'xsd_namespace' Literal )

[6]  NamespaceScope  ::=  '*' | 'cpp' | 'java' | 'py' | 'perl' | 'rb' | 
'cocoa' | 'csharp'


JensG


-----Ursprüngliche Nachricht----- 
From: Andrew Pennebaker
Sent: Wednesday, September 11, 2013 8:36 PM
To: Thrift Users
Subject: Re: Reducing namespace boilerplate?

Works for me! I just wish this were documented better.


On Wed, Sep 11, 2013 at 12:48 PM, Ben Craig <be...@apache.org> wrote:

> I think (but I'm not sure) that "namespace * com.blah.blah" will do what
> you want.
>
>
>
> From:   Andrew Pennebaker <ap...@42six.com>
> To:     Thrift Users <us...@thrift.apache.org>,
> Date:   09/11/2013 09:59 AM
> Subject:        Reducing namespace boilerplate?
>
>
>
> If I want my .thrift to be compatible with C++ and Java, I think I have 
to
> write both:
>
> namespace cpp com.blah.blah
>
> and:
>
> namespace java com.blah.blah
>
> Which seems redundant when the namespaces are the same. I'd much rather
> write something like:
>
> namespace com.blah.blah
>
> And just let all languages use the same namespace scheme. But thrift 
0.9.0
> doesn't seem to support this, throwing an empty compile error about
> syntax.
>
> Is there a way to do this in current Thrift? Are there plans in the 
future
> to support the syntax I'm after?
>
>
> 




Re: Reducing namespace boilerplate?

Posted by Jens Geyer <je...@hotmail.com>.
> I just wish this were documented better.

You mean, even better documented as here?
http://thrift.apache.org/docs/idl/
Namespace
A namespace declares which namespaces/package/module/etc. the type 
definitions in this file will be declared in for the target languages. The 
namespace scope indicates which language the namespace applies to; a scope 
of '*' indicates that the namespace applies to all target languages.

[5]  Namespace       ::=  ( 'namespace' ( NamespaceScope Identifier ) |
                                        ( 'smalltalk.category' 
STIdentifier ) |
                                        ( 'smalltalk.prefix' Identifier ) ) 
|
                          ( 'php_namespace' Literal ) |
                          ( 'xsd_namespace' Literal )

[6]  NamespaceScope  ::=  '*' | 'cpp' | 'java' | 'py' | 'perl' | 'rb' | 
'cocoa' | 'csharp'


JensG


-----Ursprüngliche Nachricht----- 
From: Andrew Pennebaker
Sent: Wednesday, September 11, 2013 8:36 PM
To: Thrift Users
Subject: Re: Reducing namespace boilerplate?

Works for me! I just wish this were documented better.


On Wed, Sep 11, 2013 at 12:48 PM, Ben Craig <be...@apache.org> wrote:

> I think (but I'm not sure) that "namespace * com.blah.blah" will do what
> you want.
>
>
>
> From:   Andrew Pennebaker <ap...@42six.com>
> To:     Thrift Users <us...@thrift.apache.org>,
> Date:   09/11/2013 09:59 AM
> Subject:        Reducing namespace boilerplate?
>
>
>
> If I want my .thrift to be compatible with C++ and Java, I think I have to
> write both:
>
> namespace cpp com.blah.blah
>
> and:
>
> namespace java com.blah.blah
>
> Which seems redundant when the namespaces are the same. I'd much rather
> write something like:
>
> namespace com.blah.blah
>
> And just let all languages use the same namespace scheme. But thrift 0.9.0
> doesn't seem to support this, throwing an empty compile error about
> syntax.
>
> Is there a way to do this in current Thrift? Are there plans in the future
> to support the syntax I'm after?
>
>
> 


Re: Reducing namespace boilerplate?

Posted by Andrew Pennebaker <ap...@42six.com>.
Works for me! I just wish this were documented better.


On Wed, Sep 11, 2013 at 12:48 PM, Ben Craig <be...@apache.org> wrote:

> I think (but I'm not sure) that "namespace * com.blah.blah" will do what
> you want.
>
>
>
> From:   Andrew Pennebaker <ap...@42six.com>
> To:     Thrift Users <us...@thrift.apache.org>,
> Date:   09/11/2013 09:59 AM
> Subject:        Reducing namespace boilerplate?
>
>
>
> If I want my .thrift to be compatible with C++ and Java, I think I have to
> write both:
>
> namespace cpp com.blah.blah
>
> and:
>
> namespace java com.blah.blah
>
> Which seems redundant when the namespaces are the same. I'd much rather
> write something like:
>
> namespace com.blah.blah
>
> And just let all languages use the same namespace scheme. But thrift 0.9.0
> doesn't seem to support this, throwing an empty compile error about
> syntax.
>
> Is there a way to do this in current Thrift? Are there plans in the future
> to support the syntax I'm after?
>
>
>

Re: Reducing namespace boilerplate?

Posted by Ben Craig <be...@apache.org>.
I think (but I'm not sure) that "namespace * com.blah.blah" will do what 
you want.



From:   Andrew Pennebaker <ap...@42six.com>
To:     Thrift Users <us...@thrift.apache.org>, 
Date:   09/11/2013 09:59 AM
Subject:        Reducing namespace boilerplate?



If I want my .thrift to be compatible with C++ and Java, I think I have to
write both:

namespace cpp com.blah.blah

and:

namespace java com.blah.blah

Which seems redundant when the namespaces are the same. I'd much rather
write something like:

namespace com.blah.blah

And just let all languages use the same namespace scheme. But thrift 0.9.0
doesn't seem to support this, throwing an empty compile error about 
syntax.

Is there a way to do this in current Thrift? Are there plans in the future
to support the syntax I'm after?