News for hackers. Stuff that matters.
Re:Avoid PHP trap by mojuba on Saturday July 05, 2008 @06:37PM (#237375)
It is not at all obvious that {...} is better than, say, array(...) for a language that has operator braces {}. PHP's array constructs are a little verbose, but they are visually distinguishable and thus are not that bad at all.

{...} as an array/dictionary literal makes more sense in a language like Python, where braces are not used otherwise.

Re:Avoid PHP trap by randallsquared on Saturday July 05, 2008 @07:04PM (#237391)
If creating a new language that looked like PHP/C/Java/etc, you could use {} for both blocks and arrays (and assoc arrays, like PHP) by making blocks a special case of arrays, conceptually. Then {0; 1; 2; 3;} would be an array of four elements, and as a bonus it would free up [] for something else. :)
Re:Avoid PHP trap by mojuba on Saturday July 05, 2008 @07:10PM (#237395)
Like in C or Perl, OK, but that makes both unreadable for humans rather than for compilers, that's what I'm saying. So the reasons behind PHP's array() construct are not trivial.