3 ms·
Nim has type inference as well, but the type still has to be known before we can use a value. From the tutorial: > Nim also has type inference ability — the c
by PMunch 8y ago
Nim has type inference as well, but the type still has to be known before we can use a value.
From the tutorial:
> Nim also has type inference ability — the compiler can automatically detect the type of a name assignment from its value, without explicitly stating the type.
- MaxBarraclough 8y agoWell that's exactly the point. It's statically typed, so of course types have to be known at compile-time, but it can use type inference rather than explicitly expressing type in declarations. Static typing with type inference is still static typing. Vaguely related: many people also confuse 'dynamically typed' and 'untyped', despite that they're not even close.
- jerf 8y agoI've seen that called "type deduction" to distinguish it from "type inference". It's a much simpler feature. Arguably it's more of a convenience, whereas "type inference" tends to have real effects on the idiomatic way to design solutions in the language. A nice one though; I wouldn't care to go back to a language where I'm double-specifying types all the time like that.