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
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
/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