-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Move callconv
, align
, addrspace
, and linksection
annotation before function parameter list
#22263
Comments
Other ( |
i think this very badly hurts the readability and searchability of functions. i assume this would also change the placement for function types? |
a strategy i use to locate code is by a project wide search for |
I realize I'm reiterating what has already been said above, but being able to easily and reliably grep/search for names of types and functions using fairly basic patterns like @xdBronch's suggestion of placing the annotations before the
It might look and read a bit awkward, but at least it remains matched by patterns like (I'm also not sure if I personally agree with the idea that "some things that come after the parameters can't reference the parameters" is a big issue or potential source of confusion in the first place. A little inelegant, maybe, but as a user it's pretty easy to accept and live with.) |
Thanks for the feedback, everyone. I'm actually starting to think that moving these annotations before the // (should `pub`, `inline`, `noinline` go before or after these annotations? I have no idea)
pub align(4) addrspace(.something) linksection(".foo") callconv(.c) fn foo() void {
// ...
} If we're doing that, then it makes sense to also move them for pub align(128) addrspace(.foo) linksection(".bar") var x: u32 = 123; I'd be interested in getting some more thoughts on this. I don't think it would introduce any grammar problems. |
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: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 thefn
keyword, to make it clear that function parameters are inaccessible in those expressions.A
zig fmt
fixup can exist for one release cycle which just moves these annotations to their new location.The text was updated successfully, but these errors were encountered: