Split out from #11834. Depends on #22261.
If callconv etc cannot reference function parameters, then it seems inconsistent for them to be written after the parameter list:
// why can't I do this? `b` is declared before the `callconv(...)` expression!
fn f(comptime b: u32) callconv(if (b) .c else .auto) void {}
So, this proposal is for a simple syntax change. callconv(...), align(...), addrspace(...), and linksection(...) annotations on functions should be moved before the parameter list, just after the fn keyword, to make it clear that function parameters are inaccessible in those expressions.
fn callconv(.c) f(comptime b: u32) void {
_ = b;
}
A zig fmt fixup can exist for one release cycle which just moves these annotations to their new location.
Split out from #11834. Depends on #22261.
If
callconvetc cannot reference function parameters, then it seems inconsistent for them to be written after the parameter list:So, this proposal is for a simple syntax change.
callconv(...),align(...),addrspace(...), andlinksection(...)annotations on functions should be moved before the parameter list, just after thefnkeyword, to make it clear that function parameters are inaccessible in those expressions.A
zig fmtfixup can exist for one release cycle which just moves these annotations to their new location.