Hi Stuart,
the relevant code has been merged via PR from fbthrift a while ago, here's
the relevant ticket:
https://issues.apache.org/jira/browse/THRIFT-2421
Note that some structures you just shouldn't do. Not everything that's
syntactically possible is also a good idea. Self-Referencing structures or
such that introduce circles will very likely produce endless loops while
serializing or some fun effects w/regard to duplicated instances when
deserializing. Thrift does not prevent you from trying that (yet), it will
just not work.
There's also something that I started a while (THRIFT-2005), ago, but the
demand for that seems limited. That approach would work without such
limitations (it basically implements the recommended workaround with some
additions on top of already existing code), but it is still only available
as a prototype, mostly because of the non-feedback I got so far.
Have fun,
JensG
PS: Did I mention that we happily review patches? ;-)
-----Ursprüngliche Nachricht-----
From: Stuart Reynolds
Sent: Monday, January 26, 2015 4:05 PM
To: [email protected]
Subject: Self referential classes
Looking at the archives:
http://mail-archives.apache.org/mod_mbox/thrift-user/201011.mbox/%[email protected]%3E
I understand that the following causes problems for C++:
struct A {
1: A a;
}
because sizeof(A)==infinity.
1-- the above .thrift compiles for in thrift 0.9.2. Are there guards
against it in later versions of thrift? If so, can there any
configuration possible surround this? (for example, ignoring the error
because C++ it not a target, or changing the C++ output to use aptr
for field members).
2 -- Are self referencing collections generally allowed? (Can't test
locally -- for now stuck with 0.9.2) e.g. :
struct A {
1: list<A> children;
}
Thanks,
- Stuart