Switch and break

Jonathan M Davis jmdavisProg at gmx.com
Thu Jan 19 16:19:07 PST 2012


On Friday, January 20, 2012 01:03:21 Matej Nanut wrote:
> I like the error DMD (-w) gives in this situation a lot. It has saved
> me precious minutes of debugging on more than one occasion. :)
> 
> And I never liked ‘warning:’s anyway. If something is dangerous enough
> to warrant a warning, the compiler may just as well enforce it in the
> language and be done with it.

That's pretty much Walter's take on it. He doesn't believe in warnings. Either 
something is an error or it's not. I'm pretty sure that he only added them 
because of complaints. And when he did, it was with -w - which makes them 
errors rather than displaying warnings but not preventing compilation as is 
normal with most compilers. It wasn't until after he got a bunch more 
complaints that he capitulated and added -wi which then makes dmd act like 
most compilers on the planet and display warnings without stopping 
compilation.

Personally, I always compile with -w and have increasingly come to agree with 
Walter's thinking on this. I've long believed that responsible programmers 
don't commit code with warnings in it. And if warnings are never acceptable, 
then why are they warnings instead of errors? The only case where I think that 
warnings can be useful is if it's for something that you know needs to be fixed 
but which you don't need to fix right away as you're editing code. But 
considering how many programmers leave warnings in (I've never understood why 
aside from laziness), having them just creates problems IMHO.

IMHO, anything which is definitively a problem should be an error, and anything 
that _might_ be a problem should be left up to lint-like tools.

The only real advantage of -w over having no warnings at this point is that it 
gives us a way to phase in errors.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list