+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

Reply via email to