On Saturday, June 16, 2018 22:56:38 DigitalDesigns via Digitalmars-d-learn wrote: > On Saturday, 16 June 2018 at 21:41:37 UTC, Jonathan M Davis wrote: > > On Saturday, June 16, 2018 14:55:51 Steven Schveighoffer via > > > > Digitalmars-d- learn wrote: > >> On 7/30/16 8:47 AM, Jonathan M Davis via Digitalmars-d-learn > >> > >> wrote: > >> > I'm writing some serialization code where I need to skip > >> > static variables. So, I have a symbol from a struct, and I'd > >> > like to test whether it's static or not. Ideally, I'd be > >> > able to do something like > >> > > >> > is(field == static) > >> > >> std.traits.hasStaticMember ? > >> > >> https://dlang.org/phobos/std_traits.html#hasStaticMember > > > > Yeah. I wrote that, and it got added to Phobos. If you'll note, > > my post in this thread was from almost two years ago. > > > > - Jonathan M Davis > > doesn't work: > > ..\..\src\phobos\std\traits.d(3823): Error: class `app.A` member > `z` is not accessible. > > What is the point of introspection if one can't get information > about a type due to it's protection level? > > For example, how is one suppose to serialize a class that has > protected and private members, which are common, when using > properties?
The fact that you can't introspect on private variables with stuff like __traits is a well-known bug, and I expect that it will be fixed at some point. But if it's serialization that you want, then as I understand it, tupleof should work to get at the direct fields of a struct or class even if they're private. And you can always look at what a serialization library like Orange did. - Jonathan M Davis