Exactly. Open this can of worms and soon PHP is something else than easy to learn.. someone already mentioned that {} thing for objects.. :)

Sidenote: There are more important things to solve in PHP 5.3 (and especially HEAD) than adding this little syntax sugar..

--Jani


Mike wrote:
In my opinion I don't think PHP would be where it is today if it wasn't
for being so easy to learn and use.

I attribute this directly to the fact that it didn't use a lot of
"syntax sugar" that is unreadable and can't be "Googled" for. You can't
Google "[]", and my guess is searching PHP.net for "[]" won't return
anything useful either.
Using Array() is SELF EXPLANATORY! Anyone can see that, search Google
for "Array" and learn something about it.
How many man hours are going to be wasted:
1. Searching for what the heck [] actually is.
2. Explaining to people that [] is the same as Array.
3. Changing coding standards for projects to prevent [] from being
used. 4. Enforcing coding standards for projects to prevent [] from being
used.
5. Trying to change [] back to Array in hopes of getting code to work on
older versions of PHP.
6. All the man hours wasted on it ALREADY that I'm sure could be much
better spent getting PHP 5.3/6.0 out.

There are enough roadblocks and other things to worry about already, why
would we want to add MORE? Especially for something with so little to
gain (if anything at all).

This isn't about "well if you don't like it, don't use it" either,
because no matter what it will be forced on people who don't like it
eventually. People who like it will be constantly changing Array() -> []
and people who hate it will be constantly changing [] -> Array(). More
wasted time.

Just my two cents.

On Wed, 2008-05-28 at 08:56 -0700, Chris Stockton wrote:
+1 for: ['foo' => 'bar'], Not sure if it was decided but -1 for ['foo':
'bar']

Here is why,

Array(), is much more confusing to someone coming with no experience in php
then []. Array() in most languages looks like a function call. So
Array('foo' => 'bar'), verse ['foo' => 'bar'], most people will more easily
understand the latter when entering into the language fresh.

I.E.:
$f = Array('foo' => 'bar');
$f('foo'); // comes to mind first right, might not for a php developer but
for a new comer maybe?

$f = ['foo' => 'bar'];
$f['foo']; // great

Gives our users options, and does not break any existing code or enforce new
programming paradigm. The change is minor and no real cost in performance.

As for existing users, I find the completely negative comments a real
hindrance on the evolution of php as a language. If something does not
damage the language but will offer benefits for a broad user base, as well
as existing code, then let it be. I for one will change every line of code I
have that uses the Array() syntax for the shorter, more WIDELY readable []
syntax.

My only curiosity is if this will turn into a ecmascript morphism and we
wind up with a new object proposal instead of stdclass, like

$oStd = {'foo' => 'bar'};
echo $oStd->foo;

... doesn't even look all that bad but feels wrong and dirty, I think I
would rather (object) ['foo' => 'bar']; :p

-Chris


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to