A switch/case too far...

Janice Caron caron800 at googlemail.com
Thu May 22 06:30:14 PDT 2008


Well, convenience and readability, of course.

    switch(typeof(a))
    {
        case B1:
            // stuff
            break;

        case B2:
            // stuff
            break;

        case B3:
            // stuff
            break;
    }

looks cooler than

    {
        auto t = cast(B1)a;
        if (t != null)
        {
            // stuff
        }
    }
    {
        auto t = cast(B2)a;
        if (t != null)
        {
            // stuff
        }
    }
    {
        auto t = cast(B3)a;
        if (t != null)
        {
            // stuff
        }
    }

(in my opinion, at least). That said, I don't really care much about
this proposal one way or the other. It's only sugar, after all.



More information about the Digitalmars-d mailing list