Re: [PHP] Array has `trailing comma`, why not the same for function parameter list?
On Sun, Oct 30, 2011 at 08:47, Nam Gi VU wrote: > It is convenient to have a trailing comma when defining an array - so as > easy to add/remove code to add/remove an entry to the array > > array( > 'key00' => 'value00', > 'key01' => 'value01', > 'key02' => 'value02', > ... > ) > > I suggest to PHP Development team to make it available in the syntax to > have a leading comma > array( > ... > , 'key00' => 'value00' > , 'key01' => 'value01' > , 'key02' => 'value02' > ) > in such way, we can thought of the leading commas as the list bulletings. > > And the same things would be lovely to be applied also to function > parameter list. I don't see why not :) > > What do you thing about my suggestion? Hope to hear from you! For feature requests such as this, please discuss it on the Internals list (CC'd on this email) and suggest it via the bug tracker at https://bugs.php.net/ (with the bug type as a "Feature/Change Request"). -- Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array has `trailing comma`, why not the same for function parameter list?
On Sun, Oct 30, 2011 at 8:47 AM, Nam Gi VU wrote: > It is convenient to have a trailing comma when defining an array - so as > easy to add/remove code to add/remove an entry to the array > > array( > 'key00' => 'value00', > 'key01' => 'value01', > 'key02' => 'value02', > ... > ) > > I suggest to PHP Development team to make it available in the syntax to > have a leading comma > array( > ... > , 'key00' => 'value00' > , 'key01' => 'value01' > , 'key02' => 'value02' > ) > in such way, we can thought of the leading commas as the list bulletings. > > And the same things would be lovely to be applied also to function > parameter list. I don't see why not :) > > What do you thing about my suggestion? Hope to hear from you! > WRT functions: while I could see how this would seem like a good idea because of the symmetry in what's going on at a very high level of abstraction, I would be against including it in a language. I don't particularly like it for arrays, but it does make it easy to add items into an array, which happens pretty often in development, especially when writing exploratory code. Function signatures, on the other hand, probably aren't changing nearly as often. At the very least, I wouldn't want to encourage people to make functions with many parameters, as it's normally a sign of poor design. This wouldn't explicitly do so, but would do so implicitly as it's only real purpose is to make it easier to add things. As far as the supporting-a-leading-comma thing goes, I'm pretty ambivalent on it. I don't really like the style outside of Haskell code, but that's just a preference. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array has `trailing comma`, why not the same for function parameter list?
It is convenient to have a trailing comma when defining an array - so as easy to add/remove code to add/remove an entry to the array array( 'key00' => 'value00', 'key01' => 'value01', 'key02' => 'value02', ... ) I suggest to PHP Development team to make it available in the syntax to have a leading comma array( ... , 'key00' => 'value00' , 'key01' => 'value01' , 'key02' => 'value02' ) in such way, we can thought of the leading commas as the list bulletings. And the same things would be lovely to be applied also to function parameter list. I don't see why not :) What do you thing about my suggestion? Hope to hear from you! -- Nam