Internal linkage - equivalent of C++ global static and anonymous namespaces

Francesco Cattoglio via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 12 01:49:36 PDT 2014


Yesterday I discovered that a global static variable in D is just 
a global variable, with no special rule about symbol visibility 
and such.

I've scrolled quickly through old discussions on the NG and read 
the relevant DIP: http://wiki.dlang.org/DIP22
It seems to me that nobody thought about reusing the module 
keyword for declaring symbols with internal linkage. It would 
look like:

file foo.d:
     module foo; // module declaration
     module uint cantSeeMe; // internal linkage attribute, hidden 
symbol
     private uint can_See_Me; // private, but symbol still visible

AFAIK, module keyword right now is only used for module 
declaration, and is not valid anywhere else. Would it make sense 
to use it in this context, too?


More information about the Digitalmars-d mailing list