Type name shadowing

ixid via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 25 05:28:39 PDT 2014


T shadow(T = int)(T a) {
	alias T = string;
	T b = "hi";
	T c = 1; // Error

	writeln(typeof(a).stringof); // int
	writeln(typeof(b).stringof); // string

	return a;
}


Are there uses for this shadowing of type names? It seems a 
little dangerous, for example ulong T could be shadowed by uint 
T. Is there a reason to allow it?


More information about the Digitalmars-d-learn mailing list