digitalmars.D.bugs - [Issue 3483] New: Eliminate read-modify-write operations for enums
- d-bugmail puremagic.com Nov 06 2009
- d-bugmail puremagic.com Nov 08 2009
- d-bugmail puremagic.com Nov 20 2009
- d-bugmail puremagic.com Nov 20 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3483 Summary: Eliminate read-modify-write operations for enums Product: D Version: unspecified Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrei metalanguage.com --- Comment #0 from Andrei Alexandrescu <andrei metalanguage.com> 2009-11-06 22:16:03 PST --- Consider: enum E { a = 5, b = 10, c = 15; } Arithmetic involving an E are accepted, e.g. E.a + 42, and that's fine because they yield type int which is not convertible back to E. The problem is that read-modify-write expressions are allowed too: E.a x; x += 42; Such operations are nonsensical because they take an enum value easily in places that have nothing to do with the actual defined values. All operations <op>= and also ++ and -- should be disabled for enums. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 06 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3483 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com --- Comment #1 from Stewart Gordon <smjg iname.com> 2009-11-08 06:51:35 PST --- This is going to break uses of enums as bit flags, which is a valid use according to the docs. Maybe we need a separate "bitflags" type, which would differ in this and other respects.... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 08 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3483 --- Comment #2 from Stewart Gordon <smjg iname.com> 2009-11-20 14:55:18 PST --- Moreover, "next value" is a perfectly valid concept for enums, so I don't get why you want ++/-- removed at all. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 20 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3483 --- Comment #3 from Andrei Alexandrescu <andrei metalanguage.com> 2009-11-20 16:54:22 PST --- (In reply to comment #2)Moreover, "next value" is a perfectly valid concept for enums, so I don't get why you want ++/-- removed at all.
It would be just too odd and requiring a lot of complication to define properly. enum E { a = 5, b = 8, c = 15; } Increment of an enum really becomes a series of if/else statements (if it's 5 make it 8 etc.) or would just increment the actual value leading to values that are not part of the enum. What to do? Then what do you do when you are at the end of the scale and want to increment? Answers could be found, the problem is that reasonable people may think different answers are best, and expect different behaviors. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 20 2009









d-bugmail puremagic.com 