On 2011-12-16 10:34, Walter Bright wrote:
On 12/14/2011 11:41 AM, Adam Wilson wrote:
Hello Everyone,
I want to start this conversation by pointing out that I come from a
C/C++/C#
background and my ideas and frustrations in this post will be colored
by that
history.
When I first approached D, the idea of an 'export' confused me. I've
since
figured out, at least in libraries, that in C# terms D's 'export' means
'public'.
I'm not too familiar with C#'s public, but what D 'export' means is a
function is an entry point for a DLL. In the Windows world, that means
it gets an extra level of indirection when calling it, and it
corresponds to:
__declspec(export)
in Windows compilers.
However, this raise a problem, specifically, how do I export a
protected member from a dynamic library?
Do you mean how does one directly call a protected function inside a DLL
from outside that DLL, without going through the virtual table?
What I think he wants is a member that is overrideable in a subclass
outside of the DLL but otherwise only reachable within the module its
defined in.
// foo.dll/foo.d
class Foo
{
export protected void foo () {}
}
// foo.dll/bar.d
auto foo = new Foo;
foo.foo; // error can't access protected member
// bar.dll/bar.d
class Bar : Foo
{
export protected override void foo () {} // it's fine to override
the method since it's protected, it's reachable in this dll since it's
exported
}
--
/Jacob Carlborg