-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
p1214 - cAll the Things! - motivation, numbers, examples for C++29 #3
Comments
Got you some examples of error messages that show how things might be improved :) |
Thanks, I'll try to Tony Table them. Note I don't think I will submit this paper for Pre-Kona? Since it doesn't seem like it's worth adding to the mailing list pile to churn. (Maybe by the time Cologne or Belfast roll around, or the meeting after that?) This will certainly help when I start working on Dang (Derpstorm Clang, haaaah). |
I don't think it's worth updating it before you intend to present bring it again before EWGI, unless you want to gather more feedback from other places before that :p Also great pun, I love it ❤️ |
Deducing |
We probably need to check which debuggers ignore |
I'll make sure to add that to the paper soon, thanks for pointing it out Morwenn! |
Alternative title: "Removing Barriers to Entry: std::invoke for the masses". |
Alternative title: "Projections for everybody: better call syntax for Callables". |
It's somehow the easiest and least important argument in the mix, but we could mention that it would also probably help greatly simplifying the standard wording itself in some places x) Your wording only introduces the one required to get the feature into the standard, but imagine the heaps of INVOKE stuff that could be removed everywhere. Maybe that should come with another paper though. |
I'm reading the proposal again and I think that there is an impact on the standard that you didn't mention: INVOKE - and therefore |
I'm adding this link to the motivation under a new section about compile time: https://eggs-cpp.github.io/invoke/benchmark.html |
Numbers on a better invoke: https://github.com/eggs-cpp/invoke Someone started working on a compiler version of this. I'll probably do my own in GCC and Clang too... |
So, since P1214 isn't likely to move before we can present actual numbers from an actual implementation in a compiler, I'm opening this issue to gather all the feedback & numbers I can provide. That way when it may have chances to pass EWGI and not to die another sad death before EWG.
No need for the bloated
<functional>
(this section is probably less impactful now that we have modules)
One thing that the paper does not mention is that
<functional>
is often included forstd::invoke
only [citation needed] and that<functional>
is known for being one of the slowest headers to parse:<memory>
and<functional>
is currently not resulting in any significant compile-time speed up when building Magnum itself, projects using Magnum reported compile times being shorter by 20–30% as a result of this change. »<functional>
, single-handedly responsible for killing compile times across the world. »Modules might change this, but the world probably won't fully move to modules until build systems and IDEs are ready to handle them.
std::invoke
is comparatively slow to compileAccording to the benchmarks of Eggs.Invoke,
std::invoke
is 1.5 to 18 times slower to compile than an equivalent plain function call, and the compilation process uses up to 12 times as much memory. It is quite underwhelming for such a small fundamental function.Better error messages
The feature isn't implemented yet in compilers, but using normal functions as examples should give an example of how error messages can be improved (is there a simple way to make Tony Tables GitHub issues?):
This snippet gives the following output on the Compiler Explorer with GCC 8.2 :
With Clang 7:
And with MSVC 19.16:
Now take the same snippet but without
std::invoke
:Here is the error message with GCC 8.2:
With Clang 7:
And with MSVC 19.16:
It should give a good idea of how the proposal should be able to improve error messages. It is worth noting that no compiler actually points to the definition of
func
on failure whenstd::invoke
is used.A better debugging experience
Some areas such as the video game industry have a need for interactive debugging and fast debug builds. Release builds tend to collapse calls to
std::invoke
into the appropriate underlying function call, but debug builds need to retain information aboutstd::invoke
and its helper functions.Having language support for callables removes the aforementioned unneeded extra debug information - and hence can help reducing the size of the debug binary -, but also allows for a smoother navigation through function calls when debugging. In the current state of things, debugger implementers can "ignore"
std::invoke
as some already ignorestd::move
andstd::forward
and jump intostd::function::operator()
for the sake of a smoother debug navigation, but having language support would give the same experience without requiring implementers to tweak their debuggers.Once generic libraries start moving away from
std::invoke
to generic language callables, it might drive their adoption in the areas that require a smoother debugging experience.Links about issues with the debugging experience:
There might be more special cases in the future
In P0847R2, it is mentioned that the new kinds of member functions proposed don't follow the usual rules of member function pointers and give the following example:
This means that depending on how you declare your member function, you might get different results on how it is possible to invoke a pointer to it. I think that it's yet another case where P1214 makes things better overall. It might be something worth mentioning in P0847 if the authors are fine with it.
Related proposals
P2826 mentions that this proposal could be useful to pointer-to-member-functions directly for their proposed replacement function feature.
It makes library implementers life easier
Once library implementers (including standard library ones) start relying on this feature, it will free there time to implement you favourite features faster! :D
(don't include this one in the paper)
The text was updated successfully, but these errors were encountered: