On 2/18/14, 11:56 AM, Steven Schveighoffer wrote:
On Mon, 17 Feb 2014 22:53:15 -0500, Walter Bright
<[email protected]> wrote:
On 2/17/2014 6:17 PM, Steven Schveighoffer wrote:
How is this advantageous? It just seems annoying...
Because it makes the programmer's intent clear - are all the cases
accounted for, or are there defaults?
Of course, no compiler can make you write correct code. But if you're
going to write a default anyway, odds are you'll choose the right one.
I think your anecdotal experience with exception specification in Java
is at odds with this expectation.
We all know programmers who are faced with seemingly annoyance hoops to
jump through jump through them with the least possible effort.
-Steve
Exactly. Programmers will just put "default: break" because of this
annoyance without thinking too much if it should be this or assert(0).
I think that "final switch" should have the function of checking that
you covered all cases, be it with a default case or not.