[Issue 10258] Add hasAccess trait

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 3 16:09:58 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10258


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2013-06-03 16:09:56 PDT ---
> Using is(typeof()) to check accessibility is a hacky workaround

Actually, according to Don (from what I recall in a discussion on unusable init
values), I don't think that that necessarily even works. You may be forced to
use __traits(compiles, foo) instead.

Regardless of that though, I'm not sure that it's really a hacky workaround.
What if accessibility isn't the only problem? It seems to me that specifically
checking for whether you have access is like checking file permissions before
trying to read a file. Even if you have permissions, there are a host of other
reasons that reading the file could fail, so checking for permissions
explicitly doesn't generally buy you much - if anything. You only care why you
can't read the file when you're trying to react differently for different error
conditions, and I doubt that you generally care that you can't use a symbol due
to access level as opposed to something else, so I would expect that checking
for whether something compiles would be enough and might even save you having
additional checks.

That doesn't mean that we shouldn't add something like this, but I question its
general utility.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list