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

- Thread: https://externals.io/message/89057
- Original archive: https://news-web.php.net/php.internals/89057
- Started by Sammy Kaye Powers on 2015-11-03T19:22:12+00:00
- Messages: 6
- RFC: Trailing commas in list syntax (Implemented (PHP 7.2)) — https://externals.io/rfc/list-syntax-trailing-commas.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

---

## #89057 — Sammy Kaye Powers — 2015-11-03T19:22:12+00:00

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

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

---

## #89060 — Bishop Bettini — 2015-11-03T21:33:06+00:00

URL: https://externals.io/message/89057#89060 · In reply to: #89057

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

---

## #89075 — Peter Petermann — 2015-11-05T13:09:46+00:00

URL: https://externals.io/message/89057#89075 · In reply to: #89057

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

---

## #89084 — Andrea Faulds — 2015-11-05T16:14:48+00:00

URL: https://externals.io/message/89057#89084 · In reply to: #89057

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/

---

## #89086 — Marcio Almada — 2015-11-05T19:29:09+00:00

URL: https://externals.io/message/89057#89086 · In reply to: #89057

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.

---

## #89097 — Benoit Schildknecht — 2015-11-07T23:44:52+00:00

URL: https://externals.io/message/89057#89097 · In reply to: #89057

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,
