Revisit trailing commas in function call parameters?
| From: | Christian Schneider | Date: | Wed, 17 Jun 2015 12:05:37 +0000 |
| Subject: | Revisit trailing commas in function call parameters? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-86730@lists.php.net to get a copy of this message | ||
Hi there,
now that syntax for variadic functions was added I quickly wanted to ask whether allowing trailing
commas for function calls could be reconsidered.
It is a very small change to the language allowing something like
my_variadic_function(
"foo",
"bar",
"qux",
);
which makes adding/removing additional parameters a little easier: No comma has to be added/removed
from the last line.
Previously this was considered unnecessary but maybe things changed enough to reconsider it? It
doesn't involve any BC break and I attached the very simple patch needed in the master branch.
If people still consider it more harm- than useful then please don't flame me and I'll
shut up again :-)
Cheers,
- Chris
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index 9612324..f299f3e 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -639,7 +639,7 @@ return_type:
argument_list:
'(' ')' { $$ = zend_ast_create_list(0, ZEND_AST_ARG_LIST); }
- | '(' non_empty_argument_list ')' { $$ = $2; }
+ | '(' non_empty_argument_list possible_comma ')' { $$ = $2; }
;
non_empty_argument_list: