Re: RFC: Short syntax for Arrays (redux)
| From: | Michael Shadle | Date: | Wed, 01 Jun 2011 20:37:01 +0000 |
| Subject: | Re: RFC: Short syntax for Arrays (redux) | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52703@lists.php.net to get a copy of this message | ||
On Wed, Jun 1, 2011 at 1:01 PM, Pierre Joye <pierre.php@gmail.com> wrote:
> I modified the vote page, pls move your votes to the desired syntax
> (or global -1)
This is a good idea to group things like this.
Back on the soapbox. All of this is just to reduce typing "array" (5
characters) before things?
Old:
$foo = array('a' => 'b', 'c' => 'd');
More than likely new:
$foo = ['a' => 'b', 'c' => 'd'];
5 character difference for each array being saved. That's it. At the
expense of syntax highlighters, IDEs, books, all becoming outdated and
need to be updated. For a language construct that has been around for
what, 10 years?
Oh, and for anyone desiring a ":" for this new shorthand, why stop at
array shorthand. Why not change this from:
foreach($foo as $key => $val)
To:
foreach($foo as $key: $val)
That would save one character for each array iteration like that.
Also - if we're worried about saving characters and shorthand why not
just remove the "$" language construct? That's a LOT of keystrokes. In
my WordPress install, that's 75,412 characters saved. Versus 6,960
"array(" matches, which would save 34,800 characters.
These were quick examples from a coworker. Just another PHP user who
said "wait why would they make another way to express an array?"