News for hackers. Stuff that matters.
Re:Discipline Doesn’t Scale by Chris_Newton on Wednesday October 21, 2020 @06:37AM (#24846458)
The compiler needs that information for checking, and the programmer, and the maintenance programmers who follow behind, need that information so they know how to call the thing. On the other hand, you can usually infer the result types of expressions by a simple forward process.

Possibly unpopular opinion: I am wary of relying on type inference for return types, other than for a function defined locally where you can easily see the implementation at the same time as the code calling it. Code like

    auto x = calculate_some_complicated_thing()
    ...
    do_something_with(x)
has a similar obscurity problem to code like

    do_something_impressive(true, false, false, true)
in that to understand what the code is doing at this level, you have to read the interface documentation for the function you’re calling anyway, and then you’re hoping that you get everything in the right place because your tools might not be able to warn you if you don’t.
Re:Discipline Doesn’t Scale by bartvk on Wednesday October 21, 2020 @07:02AM (#24846579)
In practice, type inference for return types works fine for the work I do (iOS development). Initializers are blindingly obvious anyway, and other functions are often members of an object or a struct. There are barely any bare functions.
Re:Discipline Doesn’t Scale by heavenlyblue on Wednesday October 21, 2020 @05:17PM (#24852286)
Can’t members return other objects?
Re:Discipline Doesn’t Scale by bartvk on Wednesday October 21, 2020 @10:34PM (#24854378)
Yeah but coding style dictates that the member is then named "makeWidget()". Any confusion about the returned type is minimal, IMHO.