Fixing module-scope private

Jacob Carlborg doob at me.com
Mon Jan 28 12:10:15 PST 2013


On 2013-01-28 15:15, Dicebot wrote:
> OK, I have gathered most of the data I wanted and writing DIP right now.
>
> Only moment not perfectly clear for me are serialization libraries and
> private. Can someone who has been doing similar things provide few
> snippets of serializing fields/variables serializer has no access to, in
> a way it is done now?
>
> I have asked Jacob via e-mail about his Orange but may be someone else
> can stand up.

Orange uses ".tupleof" to iterate all fields and also to get/set the 
value of a field. This will bypass the protection attribute and allows 
to get/set private/protected/package fields. The serializer would be a 
lot less user friendly if the user had to manually serialize each 
protected field.

The serializer also uses __traits(getAttribute) for the fields and 
classes/structs to any attached attributes. If the above cannot work for 
private fields I guess there's back to using mixins to a static fields 
which are a uglier than attributes.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list