News for hackers. Stuff that matters.
Re:A Failed Experiment with Python Type Annotations by blub on Tuesday June 11, 2019 @05:46PM (#20159813)
"[...]You cannot annotate a function as returning `auto` in C++. `auto` and its variants in other languages are useful for eliding redundant type declarations. Especially long ones that use generics/templates. `auto foo = MyContainer<Tuple<int, str>>();` or whatever is nice than having to double write the type declaration. But, in C++ or java, if you write a function that returns a Mycontainer<Tuple<int, str>>, you have to write that in the function.[...]"

Maybe I'm misunderstanding something, but one can write a function auto foo() in C++ and the return type is inferred. Lambda functions infer the return type by default.

Re:A Failed Experiment with Python Type Annotations by joshuamorton on Tuesday June 11, 2019 @05:56PM (#20159877)
Yuck, apparently I missed this happening. Its still (I think) true in java, where you can't have a function return `var`.
Re:A Failed Experiment with Python Type Annotations by kjeetgill on Wednesday June 12, 2019 @02:52AM (#20162351)
You're correct about Java. It was an explicit decision that the only local variable's type declarations and lambda parameters may be inferred with `var`.

This excludes, as you mentioned, the return types of a function, its parameter's types, as well as the types of fields in a class.

Re:A Failed Experiment with Python Type Annotations by clord on Tuesday June 11, 2019 @08:19PM (#20160711)
It’s only true if you have the function body available for deduction. Headers/decls need types.