# rfc:trailing-comma-function-args

- Thread: https://externals.io/message/66164
- Original archive: https://news-web.php.net/php.internals/66164
- Started by Rasmus Schultz on 2013-02-22T21:29:12+00:00
- Messages: 3
- RFC: trailing-comma-function-args (Declined) — https://externals.io/rfc/trailing-comma-function-args.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #66164 — Rasmus Schultz — 2013-02-22T21:29:12+00:00

URL: https://externals.io/message/66164#66164

I've been thinking about this RCF for a while now:

https://wiki.php.net/rfc/trailing-comma-function-args

It just doesn't seem necessary - the only time I've ever found something
like this to be necessary, is when a function takes closures or other very
long arguments, some of which are optional... but actually, writing this in
a VCS-friendly way is already possible:

$tree->traverse(
    $tree
    ,
    function($node) {
        // ...
    }
);

... version 2 ...

$tree->traverse(
    $tree
    ,
    function($node) {
        // ...
    }
    ,
    function($node) {
        // ...
    }
);

This actually comes out more legible, in my opinion.

What really irks me about this patch, is that the trailing comma implies
that another optional argument may exist - it really doesn't make the code
more intuitive to read. The example on the page (using fopen) really isn't
a realistic use-case - who would break a couple of simple arguments into
individual lines like that?

Just my two cents...

- Rasmus

---

## #66165 — Sebastian Krebs — 2013-02-22T21:46:49+00:00

URL: https://externals.io/message/66164#66165 · In reply to: #66164

2013/2/22 Rasmus Schultz <rasmus@mindplay.dk>

> I've been thinking about this RCF for a while now:
>
> https://wiki.php.net/rfc/trailing-comma-function-args
>
> It just doesn't seem necessary - the only time I've ever found something
> like this to be necessary, is when a function takes closures or other very
> long arguments, some of which are optional...


I must say, that I find this RFC completely useless. In my opinion when one
has such a long parameter list (or too long variable names),
that he must break the call onto several lines, the additional line in the
vcs' diff is the minor problem.


> but actually, writing this in
> a VCS-friendly way is already possible:
>
> $tree->traverse(
>     $tree
>     ,
>     function($node) {
>         // ...
>     }
> );
>
> ... version 2 ...
>
> $tree->traverse(
>     $tree
>     ,
>     function($node) {
>         // ...
>     }
>     ,
>     function($node) {
>         // ...
>     }
> );
>
> This actually comes out more legible, in my opinion.
>
> What really irks me about this patch, is that the trailing comma implies
> that another optional argument may exist - it really doesn't make the code
> more intuitive to read. The example on the page (using fopen) really isn't
> a realistic use-case - who would break a couple of simple arguments into
> individual lines like that?
>

/sign
Especially about the "implies, that another optional argument may exist":
One does not simply add arbitrary arguments to a function call. Except when
the function signature changes, but in this case (to repeat myself) the
additional diff-line is negligible.


>
> Just my two cents...
>

My too


>
> - Rasmus
>



-- 
github.com/KingCrunch

---

## #66169 — Florian Anderiasch — 2013-02-23T09:03:37+00:00

URL: https://externals.io/message/66164#66169 · In reply to: #66165

> /sign
> Especially about the "implies, that another optional argument may exist":
> One does not simply add arbitrary arguments to a function call. Except when
> the function signature changes, but in this case (to repeat myself) the
> additional diff-line is negligible.

I've thought about this, and the only function I'm using often enough to
have this change be needed/nice/finally there is sprintf - it's the only
function with variable number of arguments that's bitten me with the
trailing comma at least once a month - but not a single other function I
can think ok. (Maybe I should use more var_dump though...)

Greetings,
Florian
