[Issue 9761] New: version(x) in enums

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 19 13:59:57 PDT 2013


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

           Summary: version(x) in enums
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: halloaron at web.de


--- Comment #0 from halloaron at web.de 2013-03-19 13:59:56 PDT ---
enum : string
{
    name0 = "betty",
    name1 = `max`,
    name2 = r"wysiwyg string",
    name3 = x"0A",
    name4 = x"00 AA BB CC DD EE FF 00",
    name5 = "hello " ~ `world`,
    name6 = "ab" "cdefg",
    name7 = "foo"c

    version(none)
    {
        name8 = "otherstring"
    }
}

dmd(DMD32 D Compiler v2.062) result:

$ dmd enum.d

  Error: found 'version' when expecting ','
  Error: basic type expected, not (
  Error: function declaration without return type. (Note that constructors are
always named 'this')
  Error: type only allowed if anonymous enum and no enum type
  Error: if type, there must be an initializer
  Error: found '{' when expecting ','
  Error: unrecognized declaration


Is it useful?

Example:

enum : string
{
    version(x) // for enum of type wstring or dstring
    {
        name0 = "dark"
    }
    version(y)
    {
        name0 = "bright"
    }
}

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