Thread overview
Method of another module is callable, even if they is private.
Oct 12, 2013
Namespace
Oct 12, 2013
Andrej Mitrovic
Oct 12, 2013
Namespace
October 12, 2013
A.d:
----
import B;

class Foo {
public:
	void call(Bar b) {
		b.test(42);
	}
}

void main() {
	Bar b = new Bar();
	Foo f = new Foo();
	f.call(b);
}
----

B.d:
----
import std.stdio;

class Bar {
private:
	void test(int id) {
		writeln("Bar called with ", id);
	}
}
----
As expected:
Output: A.d(6): Error: class B.Bar member test is not accessible

But with this little change of A's Foo class:
----
class Foo {
public:
	void call(Bar b) {
		void delegate(int) dg = &b.test;
		dg(42);
	}
}
----

It works: Bar.bar with 42

Bug or feature? :P
October 12, 2013
On 10/12/13, Namespace <rswhite4@googlemail.com> wrote:
> Bug or feature? :P

Has to be a bug. Reduced:

-----
module a;
import b;

void main()
{
    auto s = S();
    auto f = &s.f;  // no error
    f();  // no error

    auto sf = &S.sf;  // error
}
-----

-----
module b;
struct S
{
    private void f() { }
    private static void sf() { }
}
-----
October 12, 2013
On Saturday, 12 October 2013 at 19:07:44 UTC, Andrej Mitrovic wrote:
> On 10/12/13, Namespace <rswhite4@googlemail.com> wrote:
>> Bug or feature? :P
>
> Has to be a bug. Reduced:
>
> -----
> module a;
> import b;
>
> void main()
> {
>     auto s = S();
>     auto f = &s.f;  // no error
>     f();  // no error
>
>     auto sf = &S.sf;  // error
> }
> -----
>
> -----
> module b;
> struct S
> {
>     private void f() { }
>     private static void sf() { }
> }
> -----

Ok, I've opened a bug report for this.
Otherwise it would be a nice C++-friend like feature. :D Of course, a bit protection would be needed.