It already does that elsewhere, yet strange backwards type definitions are much less readable by default to most programmers. It's like making us learn French when we could have learned British English, assuming American English as a starting point.
Even c++ allows you to put return types on the right. Why? Because putting the types on the right allows return type deduction. I think it's better to have a single syntax (all types on the right) rather than 2 syntaxes like c++ has.
It depends... if your return type is nested inside a class and you're defining a member function, you'll have to write down a qualified return type name before the qualified member function name, whereas if the return type follows the function name, it can be unqualified because at that point the class extends the scope used for name lookup.
I am not a rust expert, but I assume the recent many programming languages have a keyword for function declaration is so that functions can be first class objects.
I don't think it should be designed to save keystrokes at the cost of readability.
It already does that elsewhere, yet strange backwards type definitions are much less readable by default to most programmers. It's like making us learn French when we could have learned British English, assuming American English as a starting point.
Plenty of other languages including a large percent of recent languages have the return type on the right.
Haskell, Visual Basic, Scala, F#, Go, (Rust), Kotlin, TypeScript, Swift.
Even c++ allows you to put return types on the right. Why? Because putting the types on the right allows return type deduction. I think it's better to have a single syntax (all types on the right) rather than 2 syntaxes like c++ has.
https://medium.com/@elizarov/types-are-moving-to-the-right-2...
I think you have to be careful when presuming to speak for "most programmers".
2 replies →
It depends... if your return type is nested inside a class and you're defining a member function, you'll have to write down a qualified return type name before the qualified member function name, whereas if the return type follows the function name, it can be unqualified because at that point the class extends the scope used for name lookup.
http://www.stroustrup.com/C++11FAQ.html#suffix-return
I am not a rust expert, but I assume the recent many programming languages have a keyword for function declaration is so that functions can be first class objects.
This is one of the most trivial points I've ever heard for liking or disliking a programming language.