www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9761] New: version(x) in enums

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: halloaron web.de



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: -------
Mar 19 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9761


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Maybe this is a dupe.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9761


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



17:34:28 PDT ---

 Is it useful?
Yes because it avoids having to copy-paste entire enum definitions in version blocks just to modify a few members. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 19 2013