Why 'getSymbolsByUDA' filters private members?

Simen Kjærås simen.kjaras at gmail.com
Mon May 28 05:43:23 UTC 2018


On Sunday, 27 May 2018 at 17:42:15 UTC, Sobaya wrote:
> I'd like to get symbols that have an UDA.
>
> But when the member is private, it is not obtained.
>
> And I found a comment saying "Filtering inaccessible members" 
> in the source.
>
> Why is it necessary to filter out private members?

Since the members are private, they're not visible to code in 
other modules. getSymbolsByUDA is in std.traits, which is another 
module, so code in it can't interact with the private members.

There is definitely an argument to be made for allowing 
reflection access to private members from other modules, but the 
buck has to stop somewhere, and this is a complex problem. If 
'private' is to respected at all, clearly we can't have a 
different module call our private methods, or read our private 
fields. That means something as simple as a wrapper around a 
function can't work.

--
   Simen


More information about the Digitalmars-d-learn mailing list