atom feed88 messages in net.php.lists.internalsRE: [PHP-DEV] Proposal: Array syntax
FromSent OnAttachments
57 earlier messages
Marco TabiniNov 5, 2003 10:29 am 
Michael WalterNov 5, 2003 10:30 am 
Michael WalterNov 5, 2003 10:36 am 
George SchlossnagleNov 5, 2003 10:37 am 
Andrei ZmievskiNov 5, 2003 10:39 am 
George SchlossnagleNov 5, 2003 10:56 am 
David EndersonNov 5, 2003 11:03 am 
Marco TabiniNov 5, 2003 11:11 am 
Shane CaraveoNov 5, 2003 11:13 am 
Michael WalterNov 5, 2003 12:26 pm 
Greg MacLellanNov 5, 2003 12:40 pm 
Robert CummingsNov 5, 2003 1:08 pm 
David EndersonNov 5, 2003 1:20 pm 
Sara GolemonNov 5, 2003 2:41 pm 
George SchlossnagleNov 5, 2003 3:00 pm 
Wez FurlongNov 5, 2003 4:06 pm 
Christian SchneiderNov 5, 2003 5:07 pm 
Ard BiesheuvelNov 5, 2003 5:27 pm 
Christian SchneiderNov 5, 2003 5:50 pm 
Andi GutmansNov 6, 2003 12:03 am 
Stig S. BakkenNov 6, 2003 12:58 am 
Kouber SaparevNov 6, 2003 1:25 am 
Mike RobinsonNov 6, 2003 3:31 am 
Andi GutmansNov 6, 2003 4:04 am 
Ford, Mike [LSS]Nov 6, 2003 4:09 am 
Alexey TrunyovNov 6, 2003 4:16 am 
Ford, Mike [LSS]Nov 6, 2003 4:28 am 
Sascha SchumannNov 6, 2003 4:30 am 
Andi GutmansNov 6, 2003 5:28 am 
Sascha SchumannNov 6, 2003 5:46 am 
Stig S. BakkenNov 6, 2003 6:33 am 
Subject:RE: [PHP-DEV] Proposal: Array syntax
From:Ford, Mike [LSS] (M.F@lmu.ac.uk)
Date:Nov 6, 2003 4:09:54 am
List:net.php.lists.internals

On 05 November 2003 17:19, Marco Tabini wrote:

Ford, Mike [LSS] wrote:

On 05 November 2003 17:06, Marco Tabini contributed these pearls of wisdom:

Christian Schneider wrote:

Marco Tabini wrote:

$a = [[1,2,3],[1=>[1,3,2,2], "a"=>[[1,2,3,4],4,[1,2]]];

$a = array(array(1,2,3),array(1=>array(1,3,2,2), "a"=>array(array(1,2,3,4),4,array(1,2)));

Besides my previous points, something even more abominable:

$a = [1,2,$b[11]];

Is that confusing enough for you? ;-)

What's confusing about it?

The fact that $b[11] references an item of an array, while [1,2,$b[11]] assigns values to the array $a.

That's not confusing -- at least no more so than the different meanings of - in $b = -$a and $b = $c - $a.

The fact that you (and, probably, most of us) can't tell right off the bat

Bzzt! Wrong! It was because I *could* tell right off the bat exactly what it meant that I asked why it was confusing.

is a clear sign that this is a bad idea, because it's ambiguous and confusing.

And again, wrong assumption -- I asked what's confusing because to me it looks completely unambiguous and totally clear.

The same line using the current syntax, btw, would have looked like this:

$a = array (1,3,$b[11]);

Well, I can see true enough that that has the same meaning, but for me it's harder to read and interpret. I see the () first and start assuming it's a function, before my eyes and brain have time to digest that the name of the "function" is array -- result: a moment's confusion whilst I deal with the ambiguity of using function syntax for a language construct. With the [] syntax, I see the square brackets and they immediately shout ARRAY CONSTRUCTOR at me -- result: instant understanding and I'm on to the next line of code in a flash.

Cheers!

Mike