[Feature Request] Single name access when module name and content are same

tcak via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 25 07:45:16 PST 2015


I only want to discuss an idea here. I am hoping see some nice 
pros and cons from people.

---

We have this feature in D:

template something(T){
     void something(T value){ writeln( value ); }
}

something("Hello");

Because the name of template and function match each other, 
"something" is accepted as name of function.

---

Especially in Phobos, and also in my own libraries, there are 
name duplications. The cause of this is that we want to define 
things separately, hence defining a new module for them, but the 
name of module and class name becomes same. My thought/request is 
that, if the name of module and a 
variable/constant/struct/class/template/enum that is in that 
module matches each other exactly, as seen in the example above, 
without name duplication, access should be passed to that 
variable/con... etc.

Currently, by using package.d, this is supported in "made up" way 
by putting programmer into duplication again while using 
directories, but for module itself, I do not see any solution 
currently.

Currently, I couldn't have found any issue about adding this 
feature. So is the proposal.

module my.big.lib.createFile;

void createFile( string fname ){}

Somewhere else in the code universe:

my.big.lib.createLib("FSociety.dat");


More information about the Digitalmars-d mailing list