On 9/3/16, Martin Nowak via Digitalmars-d <digitalmars-d@puremagic.com> wrote:
> On Wednesday, 31 August 2016 at 13:12:30 UTC, Adam D. Ruppe wrote:
>> Ugh, it really should just give everything and have getMember
>> bypass it. That won't even break any code!
>
> It will, e.g. having getMember bypass protection means vibe.d
> would now serialize private members

Then just add a check in vibe.d itself to avoid serializing private
members. You can still call getProtection on the symbol and skip
serializing it.

Alternatively you can use UDAs so you can mark which fields should or
shouldn't be serializible. For example
https://github.com/msgpack/msgpack-d/blob/6046808c2e678e27cb2e2d9314241c361a6fd0ae/src/msgpack/attribute.d#L21

The bottom line is with restricting access to private symbols you have
no choice on the matter, while allowing access lets you specialize
whether to ignore the symbols or not.

Reply via email to