Orange - Free from D1/Tango

Jacob Carlborg doob at me.com
Mon Feb 18 12:19:03 PST 2013


On 2013-02-18 18:46, Steven Schveighoffer wrote:

> Hm... maybe something like this:
>
> class Widget
> {
>    Display d;
> }
>
> If you serialize Widget, then it will try to serialize d, but d is not
> owned by Widget, it's just referenced by Widget.
>
> How does Orange deal with this?

The first time Orange sees "d" it will just serialize it. If there's any 
other reference to "d", somewhere in the data structure that is being 
serialized, it will serialize a reference.

If "d" is not owned by Widget it will serialize it anyway. It doesn't 
care where it comes from.

This code:

http://pastebin.com/n1jwG9vE

Will serialize to this XML:

http://pastebin.com/tHbzVRqZ

> What if whoever wrote Widget never
> intended it to be serialized, but wasn't aware of the serialization
> library, so didn't know to mark it as @nonSerialized

I don't know if there is solution for that if the serialization library 
is using an opt-out approach. The one serializing the data structure is 
responsible.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list