News for hackers. Stuff that matters.
Re:Ten Years of “Go: The Good, the Bad, and the Meh by tialaramex on Tuesday July 18, 2023 @07:28PM (#36780352)
Right, global inference turns out to be too much inference. Function boundaries are a convenient place to draw a line.

As usual C++ choose to something much weirder and more dangerous. Instead of inference C++ can deduce types, in some cases there's no way to write a type's name so you have to deduce types, and they can be deduced at the edges of functions however unlike inference it's not an error to have ambiguity, in some cases deduction may choose one of the possibilities that it liked better even if that's astonishing for you.

Because Rust's functions must tell you their types explicitly, and because some types can't be named specifically, the result is that in Rust you have to write these functions polymorphically, even if in practice there's only one possibility. In C++ you can write the non-polymorphic function, despite not being able to say the name of the type. How do you document that? It's OK, C++ doesn't require you to provide even halfway usable documentation.

There are no comments on this comment yet.