DIP33: A standard exception hierarchy

Jonathan M Davis jmdavisProg at gmx.com
Wed Apr 3 11:11:13 PDT 2013


On Wednesday, April 03, 2013 17:41:52 Tobias Pankrath wrote:
> 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).

Yeah. I'm very much in favor of using derived classes over putting error types 
in the exceptions, but I'm not sure that breaking code using final switch is a 
good argument against the error types. You use final switch _because_ you want 
your code to break if the list of enum members changes. Then again, given the 
increased focus on not breaking user code and Walter's general attitude about 
that, I expect that he'd then be against ever adding or removing members from 
such an enum, because it _would_ break code.

- Jonathan M Davis


More information about the Digitalmars-d mailing list