[Issue 8432] write needs to print full enum type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 25 09:02:58 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8432



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-07-25 09:02:56 PDT ---
If you use enum arrays with writeln() you would typically use shorter names. My
issue is that this can make reading output ambiguous:

enum X { foo }
enum Y { foo }

void main()
{
    X x;
    Y y;
    writeln(x);
    writeln(y);
}

outputs:
foo
foo

In C++ you don't have to use the enum tag, but in D you do, and it would make
sense to output the correct type definition.

Consider another case which is why I filed this:

enum Type { Class, Struct, Enum }

struct Class { }
struct Struct { }
struct Enum { }

void main()
{
    Type[string] type = ["foo" : Type.Class];
    writeln(type);
}

outputs:
["foo":Class]

This output confused me since Class is both a struct definition and a named
enumerated value. I use writeln() almost strictly for debugging and I would
really want to see *valid* type info, which means a string representation that
could be re-inserted into code which you could practically mix in (not that I
would do that but it makes sense to keep a 1:1 mapping like this).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list