Better array syntax for PHP: Here's your chance to weigh in
Posted by Nate Abele, on Jun 09, 2008 - in PHP & CakePHP ยป News
Hi folks.
Recently there's been some discussion on the PHP internals mailing list about providing an alternate array declaration syntax for PHP.
Instead of:
it would be possible to do
-
$fields = ['id', 'name', 'created'];
Simpler, cleaner and very familiar to anyone who has done development in almost any other modern web language, especially JavaScript.
Well, there's a patch available, but 2/3 of the active PHP committers (who participated in the vote) voted against its inclusion. However, of the end-users participating in the discussion, 17 out of 20 voted in favor. Shortly before the voting was concluded, there was a call for some user-land input, so I decided to humbly submit my two pennies.
This fact has been pointed out previously, but it bears repeating: the
divide between users and committers on this issue is stark: only 1/3
of committers are in favor, but almost all users who have voiced
opinions on the issue are in favor. The people actually using the
language want something new, because in this case something new is
better. Come on guys, arrays are our bread and butter. PHP has more
support for working with arrays than it does for doing pretty much
anything else.
I can't imagine I'll be taken very seriously. I also find it hard to believe that many actual users of PHP would be against this, a fact which is all the more tragic given the rhetoric of the core committers who are against it (a full summary of the discussion can be seen at http://markmail.org/message/rsi4welftwou24p3, please note that this is not updated in real-time).
Fortunately PHP, like Cake, is an Open Source project, and even I've been known to implement and support features which I personally don't like or have no use for, if the community support behind the idea is strong enough. The same goes for PHP, so here's your chance to make your voice heard. Blog, leave comments, post to the internals list, lobby your local PHP core committer (remember to be nice).
Obviously a feature like this, even though we wouldn't be able to directly take advantage of it anytime soon, would be a great help in pushing all PHP projects, especially ours, forward to the future.