News for hackers. Stuff that matters.
Re:How C++ Resolves a Function Call by divs1210 on Tuesday March 16, 2021 @01:25AM (#26473338)
It's not unmatched, though? Never heard of Julia or Rust?
Re:How C++ Resolves a Function Call by saagarjha on Tuesday March 16, 2021 @02:03AM (#26473514)
There's not need to be dismissive. C++ has a somewhat strange position in that it is statically typed but the mechanism of type resolution is fairly loose. This, coupled with SFINAE, allows for concise declarations of things that would take much more work in other languages (or not be possible). If you've ever written a generic constraint in Rust specifying every arithmetic operation that you use in the function body, then you'll know what I mean.
Re:How C++ Resolves a Function Call by CyberRabbi on Tuesday March 16, 2021 @02:36AM (#26473679)
Yes transparent dispatch into templated functions (chosen via SFINAE) may not be everyone’s cup of tea but I prefer it to a separate macro language. No exclamation marks, looks like a normal function and later can be reimplemented as a normal function.
Re:How C++ Resolves a Function Call by simiones on Tuesday March 16, 2021 @10:35AM (#26477221)
The huge problem with SFINAE and most template techniques is that the semantics of the operation are completely different from the intention, and this always shows in error messages for any small mistake, even most of the ones your users make.

Concepts were supposed to help, but based on what I've heard, they sometimes make the error messages even worse, so I'm not sure.

Re:How C++ Resolves a Function Call by OskarS on Tuesday March 16, 2021 @05:46AM (#26474689)
What are you talking about? Julia is dynamically typed and Rust doesn't support function overloading. It's hard to imagine two worse languages to compare to C++ in response to that comment.
Re:How C++ Resolves a Function Call by UncleMeat on Tuesday March 16, 2021 @11:56AM (#26478497)
Julia and Rust always come up in discussions of C++, so a lot of people develop the idea that they are better than C++ at everything. This leads to pattern matching and just saying "why not Rust" in every discussion of C++.
Re:How C++ Resolves a Function Call by pansa2 on Tuesday March 16, 2021 @02:09AM (#26473542)
Julia is dynamically typed.
Re:How C++ Resolves a Function Call by sischoel on Tuesday March 16, 2021 @06:54AM (#26475122)
Julia is dynamically typed, but if the compiler can deduce the type of your expressions, it will usually generate specialized code that avoids dynamic dispatch. Getting rid of type instability (as it is called) is usually one of the first things I do when trying to optimize a Julia function.

The discussion about C++ lookup rules actually really reminded me of Julia, where functions are quite often overloaded and it is not always trivial to figure out which one should be called. For lack of a better source, there is something about that in this talk: https://youtu.be/TPuJsgyu87U?t=989