Func call code formatting survey (not as asinine as it sounds)

Hey handmade friends, just a survey:

How do you like to split your function calls onto multiple lines? (choose as many as apply)


  1. Open paren on same line

    1
    2
    3
    4
    5
    somefunction(
        first_argument,
        second_argument,
        third_argument
    );
    


  2. Open paren on new line
    1
    2
    3
    4
    5
    6
    somefunction
    (
        first_argument,
        second_argument,
        third_argument,
    );
    


  3. No newline on first argument, align arguments
    1
    2
    3
    somefunction(first_argument,
                 second_argument,
                 third_argument);
    


  4. Break only as needed, no newline on first argument, align arguments
    1
    2
    somefunction(first_argument, second_argument,
                 third_argument, fourth_argument);
    


  5. Break only as needed, just indent subsequent lines
    1
    2
    somefunction(first_argument, second_argument,
        third_argument, fourth_argument);
    


  6. None of the above

  7. Never, or very rarely

The purpose of this is to help me design a little language I'm working on for funsies.


[EDIT]Results, updated not-really-live![/EDIT]

Here are the results, including responses from a couple of other gamedev discord servers.

Believe it or not, there was somebody who has written a #2 or two! However, they did quality it heavily xD

1
2
3
4
5
6
7
Open paren on same line:                                              7
Open paren on new line:                                               1 (but only when it's really big)
No newline on first argument, align arguments:                        5
Break only as needed, no newline on first argument, align arguments:  12
Break only as needed, just indent subsequent lines:                   4
None of the above:                                                    1
Never or very rarely:                                                 1


Edited by drjeats on Reason: updating results
I always do nr4. Nr3 is fine to. The rest looks weird to me.
1. Unless the arguments lend themselves to obvious groupings, such as
1
2
3
4
memcpy(
    SourceBuffer, SourceBufferSize,
    DestBuffer, DestBufferSize
);


The more "modern" the language, the rarer this is, especially if they have tuples. Example for improbable language which has tuples but not a sized array type:
1
2
3
4
memcpy(
    (SourceBuffer, SourceBufferSize),
    (DestBuffer, DestBufferSize)
);

Edited by Oswald Hurlem on
Thanks guys!

Watch me make a languages with tuples, but no sized arrays type..jk. xD

I'm not certain yet I want to add tuples to this, there's a few grammar concerns to work through first :)

I use combination of 4 and 5. I don't align arguments much, but I group them depending on what they mean.
For example:
1
2
3
4
HWND window = CreateWindowExW(WS_EX_APPWINDOW, wc.lpszClassName, wc.lpszClassName,
    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
    CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
    NULL, NULL, instance, &state);

Because x, y, width, height kind of belongs together, I keep them on separate line.
I usually do #1 when there are lots of arguments or when I want to comment on one or more of the arguments. I also sometimes do the grouping that Oswald and mmozeiko talked about.
I wouldn't mind working with the other styles. I'd probably make a snarky comment about #2 (probably something involving Picasso), but it's fine as well.
I tend to do #1 or #3 and usually only if it is over 80 chars as a single line

Edited by Neo Ar on
I use 4coder line wrapping so it's displayed as 4 but the file doesn't get any new lines.
When I do it manually I use mmozeiko style.

Edited by Simon Anciaux on Reason: Typo
[EDIT] Moving the results (and updating them) to the first post[/EDIT]

Thank you so much everyone :)

Edited by drjeats on Reason: updating results
I use #1. Any function call with so many arguments I need to break it usually deserves line comments per argument anyway.
Thanks Ben :) One more tally for number 1!

(I also moved the results up to the first post)
Number 4
I usually use 3 or 4 depending on whether or not there is an obvious grouping of arguments.
#1 with grouping if I want certain arguments to go together
only when the function call makes the line really long (~120+ characters)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
	__sys_state.window = CreateWindowExA(
		0,
		wc.lpszClassName,
		"",
		WS_OVERLAPPEDWINDOW,	
		CW_USEDEFAULT, CW_USEDEFAULT,
		0, 0,
		NULL, NULL,
		instance,
		NULL
	);
Updated results, much appreciated :)