On Sun, 03 Oct 2010 04:50:26 -0400, Sergey <[email protected]> wrote:


Hi, I'm a newcomer to D. Several days ago I've stumbled upon a very strange thing about D. As I understand, module members, such as classes, structs, functions and variables can be marked with an accessibility attribute, such as private, public, package or export. Say, there's a module named "test.d":

module test;

private int x1;
public int x2;

private void fnc1()
{
}
public void fnc2()
{
}

private class C1 {}
public class C2 {}

With a great surprise, I have discovered that from another module it is still possible to access both x1 and C1, though fnc1() is inaccessible !
Can anyone explain me what does it mean ?
Thanks in advance.

This has been reported several times, it looks to me like it should be fixed.

As far as module data members, static works in C/C++, try using it here (a static member has a local name, so it cannot be used outside the file).

I don't think there's any application for static classes, though.

But private seems like a much better term for this type of thing, I think it should be supported at a module level across the board.

Related bugs:

http://d.puremagic.com/issues/show_bug.cgi?id=1161
http://d.puremagic.com/issues/show_bug.cgi?id=1441
http://d.puremagic.com/issues/show_bug.cgi?id=2225
http://d.puremagic.com/issues/show_bug.cgi?id=2775
http://d.puremagic.com/issues/show_bug.cgi?id=2830

Couldn't find any more, did a search for "private"

Most likely others have encountered the issue and found one of the related bugs above, then didn't bother to report another one.

-Steve

Reply via email to