Added isPublic, isPrivate, isProtected, isPackage, and isExport traits
Fix issue 4813
See also d-programming-language.org pull request #123
Would a getProtection trait not be more useful/flexible? Otherwise we'll end up with lots of wrappers for it unless they're added to phobos.
I think that would probably be best left for Phobos. There is no built-in representation for a protection type, so what would a getProtection trait return.
Also this approach is fairly consistent with the existing traits (isStaticFunction, isFinalFunction, isVirtualFunction, etc).
I was thinking a string. It's fine either way I guess as long as the inverse is in phobos (with the current pull I'd expect a getProtection template in phobos which returns a string with the protection type).
Given that we have isVirtualFunction, isFinalFunction, and so on, I'd go for consistency and do it like this pull request does. It would have been better to have traits that returned strings for these things, but now we're stuck with the other approach, so let's be consistent.
I just reviewed a pull request that added protection level detection to __traits: #856. How do these two compare?
I just tried using this DSYMBOL macro on my code, and it didn't pass an important test to me: it didn't give the protection on members returned from traits(getMember).
I pushed an update to mine that passes the tests I need - in addition to the macro, gotta check for various dot expressions. Take a look at the pull request Andrei linked to.
Other than that, the difference is I return a string instead of doing is... meh either way works for me, the string just seemed simpler.
Closed as it is redundant with #856.