[Issue 6180] Private has no effect on types in modules

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 25 10:11:31 PDT 2011


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


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

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


--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-06-25 10:06:39 PDT ---
In general, if a function is visible, then the compiler knows about it. If it
weren't visible, then the compiler wouldn't really see it when a module
imported the module that it's in. If it's visible but inaccessible, then the
compiler can see it, but it won't allow you to use it. So, for instance, if you
tried to use a private function, then it could complain about the function
being private, so you can't use it. But if it were not visible, then the
compiler would have to complain that you were trying to use a symbol that it
didn't know about.

Private symbols are perfectly visibile. They're just not accessible. All that
public, package, protected, and private affect is accessibility, not
visibility. They're _access_ modifiers. And overload resolution occurs _before_
accessibility is checked, which is part of the reason that you've been running
into issues with private stuff conflicting with public stuff.

You can check out this explanation with regards to C++ (which is essentially
the same):
http://meditation-art.blogspot.com/2007/11/c-function-visibility-and-accessibility.html

Also, look into NVI (Non-Virtual Inheritance). Herb Sutter discusses it in C++
here: http://www.gotw.ca/publications/mill18.htm

Assuming that private functions are overridable (which according to TDPL, they
should be, but they aren't currently in D), then derived classes can override
private functions without being able to call them. Andrei discusses it starting
at page 213 of TDPL. That wouldn't be possible if private functions weren't
visible.

-- 
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