Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You general type inference, or inferring the array length? The latter follows from the former, so it would be kind of a weird hole in the language if type inference worked everywhere except array lengths.


"Scattered through multiple lines" inference :) Such code makes another programmer analyze multiple lines to deduce types in the head.


The tooling ecosystem, for instance rust-analyzer, make this not an issue if you're reading the code in an environment that supports it. I have rust-analyzer to display inferred types when I hold `control+command`.

In other languages, this can be a brittle/expensive operation due to meh tooling. But with Rust, it tends to "just work".

Online viewers of source e.g. Github and such don't have all this information exposed yet, but they're incrementally getting there. For instance, "go to definition" works for Rust code in Github.

One could imagine a generic file format included as an artifact in source control, that online viewers could consume, to annotate spans of source code. Go to definition, show expanded type, etc.


In practice, type inference works best when paired with editor integration. Most languages/editors will give you hover-overs with inferred types, but some like rust-analyzer have started going further (the greyed-out text here is all inlaid by the editor): https://user-images.githubusercontent.com/3971413/96668192-1...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: