Bug 9761 – version(x) in enums

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-19T13:59:56Z
Last change time
2024-12-13T18:05:01Z
Assigned to
No Owner
Creator
halloaron
Moved to GitHub: dmd#17579 →

Comments

Comment #0 by halloaron — 2013-03-19T13:59:56Z
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" } }
Comment #1 by bearophile_hugs — 2013-03-19T16:44:04Z
Maybe this is a dupe.
Comment #2 by andrej.mitrovich — 2013-03-19T17:34:28Z
(In reply to comment #0) > Is it useful? Yes because it avoids having to copy-paste entire enum definitions in version blocks just to modify a few members.
Comment #3 by b2.temp — 2019-11-24T10:28:06Z
*** Issue 19174 has been marked as a duplicate of this issue. ***
Comment #4 by b2.temp — 2020-02-20T12:12:32Z
*** Issue 15601 has been marked as a duplicate of this issue. ***
Comment #5 by issues.dlang — 2024-10-29T09:02:51Z
Just adding a note here that the situation is the same with static if.
Comment #6 by issues.dlang — 2024-10-29T09:02:59Z
*** Issue 24837 has been marked as a duplicate of this issue. ***
Comment #7 by robert.schadek — 2024-12-13T18:05:01Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17579 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB