The short answer is that many people would like this feature, but we've
decided against it due to the resulting complexity in some languages like
C++.
To approximate the first struct, your best bet is to move the children thing
up a level:
struct A {
1: i32 id
}
struct AWithChildren {
1: A a;
2: list<A> children;
}
And instead of inheritance, you can always fall back on composition.
-Bryan
On Thu, Nov 18, 2010 at 7:25 PM, Martin Ritchie <[email protected]> wrote:
> Hi I'm investigating the possibility of using Thrift however, I
> currently have the need for two things that I don't think Thrift
> currently supports: self referencing structs and struct inheritance.
>
> The type of data I'm trying to serialise is a tree so Type A contains
> a list of A.
> However A also has a tree of sub-types A->B->C, A->D etc.
>
> Ideally I'd like to represent this in thrift as something like:
>
> struct A
> {
> 1: i32 id,
> 2: list<A> children
> }
>
> struct B extends A
> {
> 1:i32 extraField
> }
>
> Apologies if this has previously been discussed. Is this something
> that was ruled out? Is anyone interested and/or working on this
> already?
>
> Regards
>
> Martin
>
> --
> Martin Ritchie
>