4 ms·
"Scattered through multiple lines" inference :) Such code makes another programmer analyze multiple lines to deduce types in the head.
by zerr 4y ago
"Scattered through multiple lines" inference :) Such code makes another programmer analyze multiple lines to deduce types in the head.
- brundolf 4y agoIn 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-1c51d500-13b7-11eb-9f17-cb5fe6be4605.png https://user-images.githubusercontent.com/3971413/96668192-1...
- dymk 4y agoThe 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.