Usability of "allMembers and derivedMembers traits now only return visible symbols"

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 10:30:54 PDT 2016


On 9/3/16 6:39 PM, Andrej Mitrovic via Digitalmars-d wrote:
> On 9/3/16, Martin Nowak via Digitalmars-d <digitalmars-d at 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.

I didn't follow this closely, but clearly we need some means to access 
private members for introspection purposes. I hope we don't paint 
ourselves out of that corner. -- Andrei



More information about the Digitalmars-d mailing list