RE: Proposal: Array syntax

php.internals

David Enderson

22 years ago
I have read all the debate on this and found it very interesting. You guys were generating comments faster than I could read them! lol. I have used PHP constantly for 2 years. Most of that time has been spent using arrays very extensively and often as function parameters. For what my vote is worth, I strongly favor the newly suggested notation (+1). I'm not going to try to restate all the pros discussed and address all the cons. I prefer not to have multiple ways to do things and I found the list() function to be very counter-intuitive. I was thrilled when foreach() came out and deprecated while(), list(), each() syntax. Typing "array()" isn't very many more letters, that's true, but I type it A LOT! lol. I sometimes use it as a parameter, and VERY often have to use it to initialize variables before doing array_push() or setting array items inside loops. Using: $a = []; would be wonderful and much less clunky. As far as extending the syntax to the list() command...well...I would prefer to just find a way to deprecate it entirely, but that is probably not possible. So I guess even though it would seem to make sense I would have to vote against that because it SETS the values of its "parameters". Yes, it may be the way another language does it. All languages borrow from others, as recent discussions regarding foreach() and {} demonstrate. I believe the ultimate goal of PHP is to have a "quick and dirty" language that is easy to read, use, and learn. While Rasmus's comment about no-magic made me stop and examine this for a while, I believe it fits all those goals nicely and is an elegant reason to make an exception to the no-magic rule. No, I don't want to see stuff like: if ([1][0] == 1) { but as someone pointed out, you can make anything look nasty in C-syntax derived languages. --David -----=+=----- David Enderson Programmer Digital IMS

Robert Cummings

22 years ago
On Wed, 2003-11-05 at 14:03, David Enderson wrote:
> > I believe the ultimate goal of PHP is to have a "quick and dirty" > language that is easy to read, use, and learn. While Rasmus's comment
I complete disagree with the "quick and dirty" statement. Maybe at one time, but I think a lot of effort has gone into PHP in recent years to entertain consistency and quality. As for the new syntax, *shrug*, I'm happy with the array() function syntax, but could care less if it were implemented. I guess I'm -0 :) Cheers, Rob.
-- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'