On Wed, Dec 18, 2002 at 02:05:16AM +0900, Dan Sugalski wrote:
> How often is time to time, though? Daily? Weekly? Monthly? It's just
> not a common error, so the argument that it's useful just doesn't
> wash.
It's often enough that I don't want to completely abandon static typing,
at least for some things.
> (And the warning in your provided code is disingenuous as it is a
> valid comparison in at least some of the cases, though worth proper
> checking)
The cases where it isn't valid are hard to detect. It's a subtle error
that may not ever bite me, or it might come back to haunt me when I
least expect. I don't trust my unit-test-writing skills enough to be
able to catch an error like this.
> Of course, the C-ish languages don't help there, as the common
> solution seems to be a cast rather than fixing the code, which often
> makes things worse...
Agreed. But an explicit cast is better than no warning at all, since
with a cast my intent is clear. And C++ casts are ugly enough that I
avoid them whenever possible. The same is true of Ruby's coercion.
Paul