Enums - probably an old subject

John J john.joyus at gmail.com
Thu Nov 21 16:19:11 PST 2013


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 :)


Is this different from the "Intention.EVIL" I see in the first reply?



More information about the Digitalmars-d mailing list