|
|
|
|
|
by hamstergene
2935 days ago
|
|
That is way too oversimplified case of type inference. A huge lot of languages don't have this: let x = (f ? makeDerived1() : makeDerived2()); // no error, x is inferred to be Base
let x = 1;
x *= 2;
x = sin(x) / x; // no error, x is inferred to be Float
The problem is not just that extra computation is needed, it's language design. For example, you probably do not expect a dictionary of Floats and a zero to be a dictionary of Any, but how are you going to implement that in the compiler? |
|
And yes, the next example does need backtracking. I agree that it does need extra work in some cases. Most of the time though it's a very straightforward process.