Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Because it's not meant to! That's the tradeoff between dx and robustness. The more you infer the more your code becomes a house of cards that can break on each little code change
I think rust's attitude of inferring types only for local vars is a pretty good one. It makes it easier to program while enforcing well typed boundaries -
kobenz9043d@12bitfloat dude, your reasoning makes no sense. We're talking nominal typing, not structural. if a thing's type is X, it is so and that's the end of it. rust-analyzer knows it, I know it, why doesn't rustc? this isn't typescript for fuck sakes
-
@kobenz How doesn't it make sense? If the return type of a function is inferred and you change the implementation of that function that type might silently change
If the types of parameters of a function are inferred and you change the implementation, those inferred types might silently change
It absolutely makes sense and that's the reason why it is that way
Type inference has nothing to do with nominal vs structural typing -
kobenz9042d@12bitfloat To deny that nominal or structural typing influences type inference is like denying the moon landing was filmed on a Hollywood soundstage! Nominal typing is a rigid secret society where your "lineage" (type name) is everything, INFERRING types based solely on their declared name, like a paranoid uncle trusting only birth certificates. Now, structural typing's like a QAnon forum, INFERRING compatibility based on shared "truth" (structure) regardless of names, seeing through disguises like a conspiracy theorist connecting dots between shape-shifters. Whether it's adhering to names or seeing through them, the way types are defined and compared is the secret hand pulling the strings of what your code thinks it knows, making the type system either a deep-state plot or an anarchy of shape-shifters.
-
@kobenz I'm not sure what argument you are making. You can infer type info in both nominal and structural type systems. Just look at TypeScript
But that doesn't even matter in the first place because Rust is nominally typed
And that *also* doesn't matter because the restrictions aren't of technical nature, they exist because Rust doesn't *want* full type inference
It's a design choice to help write more robust programs -
kobenz90423h@12bitfloat xrist, dude. if a program is syntactically correct and can be typed, the compiler should be able to type it. Peace out ✌🏻
-
12bitfloat1055820h@kobenz No because it makes for less robust programs which goes against the point of rust
That's what I was trying to explain to you
Food for thought, if rust-analyzer can infer the type, why the FUCK can't rustc?
rant