Do you mean what other languages call the unit type? Or something else?
-
-
Replying to @andrew_mason1 @sgrif
No. He means omitting the return type of a function and letting the compiler figure that out itself. (I’m not a fan of it.)
1 reply 0 retweets 0 likes -
Replying to @noop_noob @sgrif
Oh god this is embarrassing. I read that as "return type interface" not "inference"
1 reply 0 retweets 1 like -
Curious, though. That's one thing I like about Haskell; why are you not a fan?
1 reply 0 retweets 0 likes -
Replying to @andrew_mason1 @sgrif
Unreadable type errors. And I like seeing the types without having to use some tool for it.
2 replies 0 retweets 2 likes -
Replying to @noop_noob @andrew_mason1
That sounds like more of an argument against a poor implementation of return type inference than an argument against return type inference. The type error should be identical to what would be there if you wrote the type explicitly.
3 replies 0 retweets 2 likes -
Replying to @sgrif @andrew_mason1
Those unreadable errors come up when modifying the body of the function, not using it. So I often end up writing the return type anyway. Also, writing the return type helps me make sure I’m returning the right thing.
3 replies 0 retweets 1 like -
Replying to @noop_noob @sgrif
> writing the return type helps me ... I think there's an argument to be made here if Rust added the inference, in that your public API should require explicit types, but private functions can support inference
2 replies 0 retweets 1 like -
Replying to @andrew_mason1 @noop_noob
This is considered a best practice in every language I've used with return type inference (Haskell and Scala)
1 reply 0 retweets 2 likes -
Replying to @sgrif @noop_noob
Yeah but I'm saying that rustc could make it enforcable, in that your crate won't compile if a publicly exposed function doesn't have an explicit type signature
1 reply 0 retweets 1 like
Visibility is a poor modifier. Binaries have different standards. Even being a library doesn't mean it's ever seeing public use.
-
-
Replying to @sgrif @noop_noob
Hmmm, I want to focus just on libs. Is there a way for rustc to know if a function is importable from another crate? Then you could enforce this at the "public use" visibility level.
2 replies 0 retweets 1 like -
Replying to @andrew_mason1 @noop_noob
I think you should consider the compiler more as a tool to lean on for support, and less of a shackle to make sure you're meeting some standard
0 replies 0 retweets 0 likes
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.