Totally agree, which is why I was baffled when I saw this code. But it goes to show that if something isn't enforced at the compiler level, "clever" developers will find a way around it.
The compiler isn't so much strict in a pedantic sense. It more nudges you to avoid bugs, in a "you may want to rethink this" way. It's actually quite nice to have someone point out potential bugs in your code.
Compile-time code restriction seems dumb. Programers can write any program they wish, stopping them for some ideological reason isnt effective. As with all the half-baked metaprogramming people restort to anyway.
That's exactly my point: when the compiler can decide not to do something you told it to you don't have full explicit control over everything. That's not a bad thing though - the compiler usually makes good decisions on your behalf. Usually.
The problem with the compiler is that it implements a language whose rules, applied to the code I just wrote, yield a bug. That this language is consistent with the spec makes it no less a problem.
My point is that I can change what I pass in in my code, and the compile time check doesn't catch it. I haven't "fundamentally missed" anything, it's you misreading my post, thanks.
What's wrong with a compiler error? "You are calling a function (Do) that is only defined by calling a function (NeverCalled) that we can't guarantee you ever call"
reply