Date: Sat, 3 Jan 2026 10:24:55 +0100
> 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.
>
If you create macros like x and y, you get what you deserve. Any reasonable
library will define their macros like MY_LIB_X to avoid these issues.
> Wouldn’t it make sense to allow some form of annotation for named
> arguments?
> void foo(int __x [[name=x]]);
>
Notice that this still doesn't solve the issue of a macro "x" expanding to
anything because that would break your attribute. If the goal is for the
user to write ".x" anyway (which are two tokens), that call site is broken
by macros anyway. I think it's best not to worry about this macro nonsense.
If we actually cared about it, we would never be allowed to add new names
to the standard library (for functions, global variables, enumerators, or
anything else) because it may break user macros.
On a more general note, myself and the other authors discussed the idea of
requiring an explicit opt-in syntax, and polled it against it for a variety
of reasons.
> 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.
>
If you create macros like x and y, you get what you deserve. Any reasonable
library will define their macros like MY_LIB_X to avoid these issues.
> Wouldn’t it make sense to allow some form of annotation for named
> arguments?
> void foo(int __x [[name=x]]);
>
Notice that this still doesn't solve the issue of a macro "x" expanding to
anything because that would break your attribute. If the goal is for the
user to write ".x" anyway (which are two tokens), that call site is broken
by macros anyway. I think it's best not to worry about this macro nonsense.
If we actually cared about it, we would never be allowed to add new names
to the standard library (for functions, global variables, enumerators, or
anything else) because it may break user macros.
On a more general note, myself and the other authors discussed the idea of
requiring an explicit opt-in syntax, and polled it against it for a variety
of reasons.
Received on 2026-01-03 09:25:10
