Mandatory return type for functions and methods
I suggest we add to the code style a requirement for functions and methods to always have return type specified explicitly. There're two points behind this.
- Signature of a function (and of a method) is documentation for fellow developers. Thus, leaving it to the compiler to infer adds a burden on a human who reads your code to do the same job.
- There's always a chance to get it plainly wrong with either a wrong guess (you meant one type, compiler inferred another) or break things later possibly in an ambiguous manner. I.e., let's say leave for the compiler to infer some types from function's return type that gets inferred itself. If it changes, compilation errors will arise from usage sights of those variables, not on call sights of the function.
I agree in general, but when I need implement some interface I often omit return type, because specify its in each implementation is little annoying.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.