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
-
It's pretty standard at the low low price of not having very extensive implicit casts.
-
I say pretty standard but I failed miserably at Hindley-Milner type inference. It's fucking cool, I agree.
-
@ScriptCoded Implicit casts don't stack well with HM, or any kind of reversible type inference. Rust has very basic implicit casts, everything else is explicit.
-
YADU13962y@ScriptCoded
Like you can't do stuff like
float f = 10
You need to do
float f = 10.0
And you also usually have other stuff, like, for example, Ocaml:
- doesnt allow adding int and float
- has a separate operator for float addition (+ is for int, +. is for float)
- doesn't allow overloading operators or functions
Rust is similar although I don't know all the details.
The reason is that the compiler needs to be able to figure out the types based on the usage, and if you have too many places where the type could be different, the compiler has trouble. -
@lorentz Ah that explains it, always wondered why not even int widening is implicit
Related Rants
Rust does type inference based on stuff I do later down in the code. Like wtf? That's cool
rant
type inference
rust