-
-
Notifications
You must be signed in to change notification settings - Fork 667
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
Allow trailing comma in argument list #1989
Comments
Is this allowed in ECMA? |
Nope. But ECMA and Haxe have rather different approaches to optionality of delimiters anyway ;) But I do quite appreciate them, because if you have this:
You can comment out/transpose any entries without breaking syntax. |
Agreed, the trailing comma in array definition is valid in Java & Haxe. |
I'm not sure about the potential side effects, since we're in a ( ) block instead of a { } , I guess this have more chances of causing some issues such as letting pass some code while the user didn't meant it. I vote that we don't touch this now. |
After the parser encounters a comma in the argument list, it expects an expression. If the next token is a closing parenthesis instead, it could just act as though the comma had not existed. There is simply no room for unintended side effects. |
I would like to see this, both in the argument lists and function calls. function a(
arg1:X,
arg2:Y,
):Z { ... } a(
arg1,
arg2,
); It is just very convenient to be able to reorder or easily add/delete lines in examples like the ones above. It's also nice when you want to enable/disable arguments to functions with conditional compilation. And finally it would be consistent with our array and map literals now. (Just realised I'm basically restating @back2dos 's points x) |
I kinda hate how that trailing comma looks, but I acknowledge that it's very useful for copy & pasting. |
Could the code editor automatically add/remove the trailing comma when commenting out/transposing? It would reconcile nice-looking comma with very easy manipulations. |
Closing in favor of #10159 |
While it's not particularly important, I would think it would be rather comfortable to allow trailing commas in argument lists. It's allowed for array and object literals, so I think it would be rather consistent and I don't see it causing any problems.
The text was updated successfully, but these errors were encountered: