On 11/21/2013 02:20 PM, monarch_dodra wrote:
When you import from a module, you only need to specify the module name
if there is ambiguity. So for example:
//----
import std.array;
void main()
{
split("hello"); //OK!
}
//----
import std.array;
import std.algorithm;
void main()
{
split("hello"); //Wait... did you want std.algorithm.split, or
std.array.split?
std.array.split("hello"); //OK! That's clearer now.
}
//----
What Andrei is saying is that an enum *could* work the same way:
enum RedBlack //For red black trees
{
Red,
Black,
}
enum BlackWhite //For Checker boards
{
Black,
White,
}
void main()
{
writeln(Red); //OK! No problem!
writeln(Black); //I'm sorry... that's ambiguous :/
writeln(RedBlack.Black); //OK! That's clearer now!
}
Whether or not it *should*, I don't know. "Why not?" I like to say :)
If both these enums are coming from a module and I also have a RedBlack
enum in my main program that has Black in it, then I guess it would be
modulename.RedBlack.Black
to call the one from the module.
Does it make sense?
I should be really in D.learn but asked that here in context ;)