Skip to content
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

zig fmt: allow multi-line function headers #2556

Closed
benjif opened this issue May 26, 2019 · 3 comments
Closed

zig fmt: allow multi-line function headers #2556

benjif opened this issue May 26, 2019 · 3 comments

Comments

@benjif
Copy link

benjif commented May 26, 2019

Currently if I have a long function header/prototype with lots of parameters, zig fmt will force all of the parameters onto a single line.

e.g.

pub fn sgemv(
    order: Order,
    trans: Trans,
    m: usize,
    n: usize,
    alpha: f32,
    a: []const f32,
    lda: usize,
    x: []const f32,
    x_add: usize,
    beta: f32,
    y: []f32,
    y_add: usize
) void {
    ...
}

... will be changed to:

pub fn sgemv(order: Order, trans: Trans, m: usize, n: usize, alpha: f32, a: []const f32, lda: usize, x: []const f32, x_add: usize, beta: f32, y: []f32, y_add: usize) void {
    ...
}
@hryx
Copy link
Contributor

hryx commented May 26, 2019

Add a trailing comma to the final parameter -- that should fix it.

pub fn sgemv(
    order: Order,
    trans: Trans,
    m: usize,
    n: usize,
    alpha: f32,
    a: []const f32,
    lda: usize,
    x: []const f32,
    x_add: usize,
    beta: f32,
    y: []f32,
    y_add: usize,
) void {
    //
}

@benjif
Copy link
Author

benjif commented May 26, 2019

Interesting, thank you. Has it been decided that this is a mandatory style? Unsure about whether or not to close this.

@hryx
Copy link
Contributor

hryx commented May 26, 2019

I believe this style is the result of already-accepted proposals/changes. Here are some relevant issues: #1003, #2181

So I would close it unless you want to bring up a counterargument to the policy or propose an enhancement to it.

@benjif benjif closed this as completed May 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants