Date: Sat, 3 Jan 2026 09:54:29 +0100
> On Jan 3, 2026, at 5:03 AM, Jan Schultke via Std-Proposals <std-proposals_at_[hidden]> wrote:
> If you need to change how the function declaration works, it's not possible to apply this new feature to existing standard library functions. However, that is a big part of the motivation, like avoiding bugs in calls to std::lerp or eliminating the vast majority of overload algorithm candidates using std::ranges::sort(.exec = e, ...).
When reading your work-in-progress proposal, I immediately noticed this problem about existing standard library functions. I’m not sure if it is feasible for the standard to prescribe argument names. They’d have to be collision-free with macros which means we can only get ugly names. Wouldn’t it make sense to allow some form of annotation for named arguments?
void foo(int __x [[name=x]]);
This kind of change would be much safer and easier to put into the standard for existing functions. It would also help to unify different implementations that use different argument names. Furthermore, this could also be used for reflecting on argument names. This kind of annotation could resolve ambiguities because of multiple inconsistent function declarations.
This would still mean that the annotation is not mandatory, but would be derived from the given name automatically.
However, we could also make the annotation mandatory and thus distinguish between positional and named parameters (and use another annotation for arguments that can be both). This would make it similar to Python.
> If you need to change how the function declaration works, it's not possible to apply this new feature to existing standard library functions. However, that is a big part of the motivation, like avoiding bugs in calls to std::lerp or eliminating the vast majority of overload algorithm candidates using std::ranges::sort(.exec = e, ...).
When reading your work-in-progress proposal, I immediately noticed this problem about existing standard library functions. I’m not sure if it is feasible for the standard to prescribe argument names. They’d have to be collision-free with macros which means we can only get ugly names. Wouldn’t it make sense to allow some form of annotation for named arguments?
void foo(int __x [[name=x]]);
This kind of change would be much safer and easier to put into the standard for existing functions. It would also help to unify different implementations that use different argument names. Furthermore, this could also be used for reflecting on argument names. This kind of annotation could resolve ambiguities because of multiple inconsistent function declarations.
This would still mean that the annotation is not mandatory, but would be derived from the given name automatically.
However, we could also make the annotation mandatory and thus distinguish between positional and named parameters (and use another annotation for arguments that can be both). This would make it similar to Python.
Received on 2026-01-03 08:54:45
