[Issue 4261] Bad textual printing of enums

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 30 05:47:47 PDT 2010


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



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2010-08-30 05:47:34 PDT ---
I'm not sure I understand what you're saying. An enum in D is a list of
symbolic values of any type (except classes).

For example:

module enums;

import std.stdio;

struct Color
{
    ubyte r, g, b;
}

enum { red = Color(255, 0, 0), green = Color(0, 255, 0), blue = Color(0, 0,
255) }

void foo(Color c)
{
    writefln("%s %s %s", c.r, c.g, c.b);
}

void main()
{
    foo(blue);
}

enums are also used in CTFE, e.g.:

enum float value = someFunc();  // CTFE

Having to use a cast everywhere for an enum would break a lot of code.

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