|
![](/i/fill.gif) |
>>> But detecting type errors isn't 100% accurate either.
>>>
>>> int x = 1 ? 5 : "hello";
>>>
>>> That's not legal, but it's not a type violation either.
>>
>> The general problem of determining whether every possible code path is
>> well-typed is undecidable. Type systems insert artificial restrictions to
>> /make/ the problem decidable. Hence, there are expressions and statements
>> which are well-typed, but do not type-check.
>
> Which is the point I'm making.
And I'm agreeing. ;-) [Although I'm not sure I got the technical terms
right...]
> We put up with saying "that'll never be
> the wrong type, but it's still illegal", so the argument that "whether
> this code is reachable is unsolvable, so we shouldn't even try" is
> equally bogus.)
Well, to be fair, the code you worked is well-typed, but /very stupid/.
The fact that it gets rejected is no big deal, really.
(OTOH, all the advocates of dynamically-typed languages seem to think
that this is /the primary reason/ that statically-typed languages suck -
because you /can't/ just do whatever the hell you want, no matter how
incoherent.)
Post a reply to this message
|
![](/i/fill.gif) |