On 06/01/2011 10:26 AM, Daniel Murphy wrote:
"Andrej Mitrovic"<andrej.mitrov...@gmail.com>  wrote in message
news:mailman.517.1306925428.14074.digitalmar...@puremagic.com...
On 6/1/11, Andrei Alexandrescu<seewebsiteforem...@erdani.org>  wrote:
Also, I think the runtime error on not handling all cases should be
eliminated as well. It's very non-D-ish and error prone in the extreme
(as unhandled cases tend to be often rare too). Right there with the
HiddenFunc error.

I get these errors all the time in GUI apps. They're a pain in the
ass, and I really want them to surface during compilation instead of
getting triggered at random during runtime.

Shouldn't final switch be the way to handle this though?

I think that should be the default behavior of switch.

It seems like
making it a compile time error will just force the programmer to insert
'default: assert(0);', which is basically what the compiler does anyway.  Or
have I missed the point?

1. Most switch statements already have a default label.

2. Those that don't should be inspected and annotated by the programmer, not rely on the compiler to automagically insert code assuming the programmer's intent.

Every single time I had that assertion firing, the cause was a bug in my code. We can't leave that to a dynamic error, particularly since unhandled cases may be arbitrarily infrequent. The current state of affairs is choosing the wrong tradeoff, pure and simple.


Andrei

Reply via email to