On Wednesday, 3 April 2013 at 15:33:53 UTC, deadalnix wrote:
On Wednesday, 3 April 2013 at 09:44:23 UTC, Lars T. Kyllingstad
wrote:
I don't see the incompatibility. This is exactly the purpose
of final switch. If the user didn't want to be forced to
handle a new error category, they'd use normal switch instead.
This is a good thing in your own code. But in phobos, this is a
guarantee to break a lot of user code when adding to the enum.
You're using final switch because you want to make statically
sure that you consider every enum member. If you now add a
another enum value the code is by definition broken regardless of
dmd issues an error or not. The same is true for any kind of
virtual dispatch (if a normal switch with default: wasn't enough
your base class method, won't be either).
You have yet to specify the problems with switch in OOP.
Maybe you meant something else, that final switch doesn't
solve?
The idiomatic way to execute code depending on a value in OOP
is virtual dispatch.