[RFC][DISCUSSION] Trailing commas in all list syntax

php.internals

Sammy Kaye Powers

10 years ago
Hey internals! The RFC to allow trailing commas to function calls & declarations has been withdrawn in favor of the a RFC that broadens the scope to all list syntax. https://wiki.php.net/rfc/list-syntax-trailing-commas The RFC to allow trailing commas for all lists is now open for discussion. :) Thanks, Sammy Kaye Powers sammyk.me

Bishop Bettini

10 years ago
On Tue, Nov 3, 2015 at 2:22 PM, Sammy Kaye Powers <me@sammyk.me> wrote:
> The RFC to allow trailing commas to function calls & declarations has been > withdrawn in favor of the a RFC that broadens the scope to all list syntax. > > https://wiki.php.net/rfc/list-syntax-trailing-commas > > The RFC to allow trailing commas for all lists is now open for discussion. >
+1 for consistency.

Peter Petermann

10 years ago
Hi Sammy,
> https://wiki.php.net/rfc/list-syntax-trailing-commas
my thoughts on this: 1) having list separators (commas) signals "there is one more item" (thats the semantic meaning of a comma in a list, right?) 2) you are right, arrays vs. other lists behave inconsistent however, if i take those two assumptions into account the solution i get to is not to allow the confusing (and IMHO bad style) of commas at the end everywhere, it is to be more strict about it and disallow it for arrays - which would also be consistent and make more sense (to me), which in return means a more clean and intuitive language. However, that would be a BC breaking change, so not for a 7.1. So my suggestion would be to put this to sleep, live with what we have, and improve (by removing this from arrays) with the next major. best regards, PP
-- Peter Petermann ProtonMail: ppetermann@protonmail.com (encrypted / based in .ch) Email: ppetermann80@gmail.com - get my public PGP key from SKS Keyservers PGP Key: http://pool.sks-keyservers.net:11371/pks/lookup?op=get&search=0x0E6DBD675836A5C7

Andrew Faulds

10 years ago
Hi Sammy, Sammy Kaye Powers wrote:
> > The RFC to allow trailing commas to function calls & declarations has been > withdrawn in favor of the a RFC that broadens the scope to all list syntax. > > https://wiki.php.net/rfc/list-syntax-trailing-commas >
My thoughts on this are much the same as my thoughts on the function call/declaration-only RFC. I think trailing commas add yet another style point for people to disagree on, and can look ugly in some contexts, yet have little benefit since most lists are not frequently changed. That being said, trailing commas in `use Foo\{ ... };` might be an exception for me, since I think those lists would be quite long and subject to frequent change, unlike function calls. Hmm. Consider me -½. Thanks.
-- Andrea Faulds http://ajf.me/

Marcio Almada

10 years ago
Hi, 2015-11-03 16:22 GMT-03:00 Sammy Kaye Powers <me@sammyk.me>:
> Hey internals! > > The RFC to allow trailing commas to function calls & declarations has been > withdrawn in favor of the a RFC that broadens the scope to all list syntax. > > https://wiki.php.net/rfc/list-syntax-trailing-commas > > The RFC to allow trailing commas for all lists is now open for discussion. > :) > > Thanks, > Sammy Kaye Powers > sammyk.me
I'm on the +1 side. This brings a little improvement for anyone managing pull requests on a daily basis. And we'll end the trailing commas debate forever. Anyone that feels the necessity for cleaner diffs will be able to pick where to use trailing commas consistently, and the ones who don't care won't be hurt, as it's opt in. PS: I've been asked about trailing commas on `use Foo\{ A, B, C, };` many times, thanks for adding this bit too. Marcio.

Benoit SCHILDKNECHT

10 years ago
Hi, Le Tue, 03 Nov 2015 20:22:12 +0100, Sammy Kaye Powers <me@sammyk.me> a écrit:
> Hey internals! > > The RFC to allow trailing commas to function calls & declarations has > been > withdrawn in favor of the a RFC that broadens the scope to all list > syntax. > > https://wiki.php.net/rfc/list-syntax-trailing-commas > > The RFC to allow trailing commas for all lists is now open for > discussion. > :) > > Thanks, > Sammy Kaye Powers > sammyk.me
I think it's a terrible idea : - Another code style, another way to write code. - It's not clean at all. - Error source : when you put a comma, that's because you want to add something. How would you know if something hasn't been deleted by another person, if you forgot something, or if it is intended ? - Some languages don't allow this. If I take the habit of putting trailing commas because that's an obligation from the company I'm working for, I'm likely to make mistakes in another languages, and so, be less productive, make more buggy code. Making my brain busy with "this is language X, remember, trailing commas aren't allowed in this one.". I'd prefer to remove existing trailing commas support from the language, for PHP 8 (because of the BC), for language consistency. My 0.02$ :) Regards,