You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by Ali Al-Shabibi <al...@cern.ch> on 2009/02/13 18:40:50 UTC
Generics
Hello,
I am trying to port one of my services to Thrift, which by the way I
think is a fantastic tool.
The service interface advertises a generic return type for some
functions. This is because, a priori, the server does not know what
datatype the incoming the request will generate
So, is it possible to define structs or lists which can contain generic
types? If not, how hard would it be to implement this? I assume this
would break support for some languages that do not support generic typing.
Thanks for your help,
--
Ali Al-Shabibi
Doctoral Student
PH-ATD
CERN - European Organization for Nuclear Research
Office: 513 R-018
ali.al-shabibi@cern.ch
Tel : +41 22 767 86 46
Re: Generics
Posted by Ali Al-Shabibi <al...@cern.ch>.
Hi Bryan,
Thanks for your answer. I thought about that, but unfortunately that
will not do for me. I'll try figure something out for this.
Thanks again,
Ali
On Feb 13, 2009, at 7:03 PM, Bryan Duxbury wrote:
> The way I usually handle this is by making the method return a
> custom struct with optional fields for each type that might be
> returned. This works if you know all of the types you *could* return
> from the method, but not if you might return anything. Thrift
> doesn't (yet) support a variant type that could contain any data
> type. As you pointed out, it could be challenging to do in some
> languages, but that doesn't mean it's not worth investigating.
>
> -Bryan
>
> On Feb 13, 2009, at 9:40 AM, Ali Al-Shabibi wrote:
>
>> Hello,
>>
>> I am trying to port one of my services to Thrift, which by the way
>> I think is a fantastic tool.
>>
>> The service interface advertises a generic return type for some
>> functions. This is because, a priori, the server does not know what
>> datatype the incoming the request will generate
>>
>> So, is it possible to define structs or lists which can contain
>> generic types? If not, how hard would it be to implement this? I
>> assume this would break support for some languages that do not
>> support generic typing.
>>
>> Thanks for your help,
>>
>>
>> --
>> Ali Al-Shabibi
>> Doctoral Student
>> PH-ATD
>> CERN - European Organization for Nuclear Research
>> Office: 513 R-018
>> ali.al-shabibi@cern.ch
>> Tel : +41 22 767 86 46
>
Ali Al-Shabibi
Doctoral Student
PH-ATD
CERN - European Organization for Nuclear Research
Office: 513 R-018
ali.al-shabibi@cern.ch
Tel : +41 22 767 86 46
Re: Generics
Posted by Bryan Duxbury <br...@rapleaf.com>.
The way I usually handle this is by making the method return a custom
struct with optional fields for each type that might be returned.
This works if you know all of the types you *could* return from the
method, but not if you might return anything. Thrift doesn't (yet)
support a variant type that could contain any data type. As you
pointed out, it could be challenging to do in some languages, but
that doesn't mean it's not worth investigating.
-Bryan
On Feb 13, 2009, at 9:40 AM, Ali Al-Shabibi wrote:
> Hello,
>
> I am trying to port one of my services to Thrift, which by the way
> I think is a fantastic tool.
>
> The service interface advertises a generic return type for some
> functions. This is because, a priori, the server does not know what
> datatype the incoming the request will generate
>
> So, is it possible to define structs or lists which can contain
> generic types? If not, how hard would it be to implement this? I
> assume this would break support for some languages that do not
> support generic typing.
>
> Thanks for your help,
>
>
> --
> Ali Al-Shabibi
> Doctoral Student
> PH-ATD
> CERN - European Organization for Nuclear Research
> Office: 513 R-018
> ali.al-shabibi@cern.ch
> Tel : +41 22 767 86 46