3 ms·
I actually like the option to have both inferred parameter and return types, primarily because they help in writing code while prototyping quickly with several
by aszen 6y ago
I actually like the option to have both inferred parameter and return types, primarily because they help in writing code while prototyping quickly with several types.
Once the code is well defined I then start adding the type annotations , often times using the ide tooling to auto generate them.
I think a good balance would be that all published packages should have type annotations added in their source code for clarity while short scripts could do without them.
- skohan 6y agoIdk I mean maybe it's a matter of taste, but I just never felt like it was that cumbersome to write type names in the function signatures. In a short script it's not like you would usually have the dozens or hundreds of function signatures it would take to make this feel like drudgery.
- aszen 6y agoWell think about writing functions inside a repl or interactive environments like jupyter notebooks or just plain scripting. Enforcing type annotations add little value in those cases and end up making the language ill suited for such use cases. Whole form type inference is actually a super power that allows for writing extremely expressive code without giving up type safety.