msgpack-d icon indicating copy to clipboard operation
msgpack-d copied to clipboard

Implement circular reference support as a msgpack D language extension

Open ghost opened this issue 12 years ago • 7 comments

Originally filed here: Msgpack-81

A first implementation is provided in this tree: ClassRefs (not tested with latest compiler yet).

I think we should consider implementing the feature as some sort of msgpack extension. Since msgpack-d is very fast, supports binary serialization (Orange doesn't), and is a small codebase with no dependencies it would be a net-win if we supported this even if it's only an extension.

ghost avatar Feb 27 '13 18:02 ghost

It's a interesting thing.

But currently MessagePack itself is now discussing the format specification. (This discussion started with adding string type proposal)

https://github.com/msgpack/msgpack/issues/128

Please wait until this discussion is finished.

repeatedly avatar Feb 27 '13 18:02 repeatedly

Sure thing, I actually saw that discussion before (it's huge) and thought it might be relevant to this. I guess you could bring this topic up with the msgpack team if it's relevant to them.

ghost avatar Feb 27 '13 19:02 ghost

https://github.com/msgpack/msgpack/blob/master/spec.md

New MessagePack format supports ext type with serveral sizes. After msgpack-d followed new format, we may use ext type for circular reference support.

repeatedly avatar Feb 17 '14 05:02 repeatedly

That's awesome to hear. I really think msgpack-d could become a de-facto library to use for serialization in D. There are other efforts of course, but they all seem to be very complicated and slow.

ghost avatar Feb 17 '14 06:02 ghost

Is there any update on that? Dealing with circular references would make serialization a whole lot easier for client code

timotheecour avatar May 22 '15 01:05 timotheecour

Here's a minimal test case:

class A{B b;}
class B{A a;}
void main(){
  auto a=new A;
  auto b=new B;
  a.b=b;
  b.a=a;
  auto data = pack(a);//CRASHES
  auto a2 = unpack!A(data);
  assert(a2.b.a==a2);
}

timotheecour avatar May 22 '15 01:05 timotheecour

hacked the code to make it work; i can try to make a pull request if anyone is still interested

timotheecour avatar May 23 '15 17:05 timotheecour