Live data from Hacker News

PHP Short Syntax for Arrays: developers say no.

wiki.php.net

61–70 of 89 posts

Re: PHP Short Syntax for Arrays: developers say no.

#61

Few people asked for, or even wanted GOTO, yet that seemed to make it through with flying colors. When people would argue against it, the rationale was "well, you don't have to use it!" Why does the same criteria not apply to short array syntax? If you don't want to use it, don't use it, but hundreds of thousands of other people likely do want it. FWIW, I first remember hearing about this in 2003/2004, and at that ti…

The votes are old. The discussion has been raised again for 5.4 ( http://markmail.org/message/fx3brcm4ekh645se )

goto is a limited goto, and the reasoning for it's inclusion makes sense when you consider the other forms of limited goto already in place (breaks, cases, try/catches). It's not an unlimited goto.

Re: PHP Short Syntax for Arrays: developers say no.

#64
post #45
post #35

Note that the feature is under discussion for 5.4 and not rejected. Chances are actually extremely good that it will be in 5.4 in some form.

i gathered the opposite from the conclusion, unless it somehow leaves a window for another patch

http://markmail.org/message/fx3brcm4ekh645se

It's being brought forth again for 5.4, and really pushed. Their is a lot of momentum from the community, and even those who voted against it before are changing their mind.

Re: PHP Short Syntax for Arrays: developers say no.

#67

Few people asked for, or even wanted GOTO, yet that seemed to make it through with flying colors. When people would argue against it, the rationale was "well, you don't have to use it!" Why does the same criteria not apply to short array syntax? If you don't want to use it, don't use it, but hundreds of thousands of other people likely do want it. FWIW, I first remember hearing about this in 2003/2004, and at that ti…

The votes are old. The discussion has been raised again for 5.4 ( http://markmail.org/message/fx3brcm4ekh645se ) goto is a limited goto, and the reasoning for it's inclusion makes sense when you consider the other forms of limited goto already in place (breaks, cases, try/catches). It's not an unlimited goto.

The wiki page would have diffused this entire post if it had the dates of the votes on it :)

I understand GOTO, but the reaction to people who thought it was a bad idea was "don't use it!", ignoring the fact that whether we use it or not, we have to deal with other peoples' code that do use it.

Re: PHP Short Syntax for Arrays: developers say no.

#68
post #58
post #28

Earlier quoted context omitted.

It's kind of JSON-wish, so this would make more sense: $bar = [1, 2, 3]; $foo = { 'bar': TRUE, 'baz': 'socks' };

For being JSONish it should be $foo = { bar: TRUE, baz: 'socks' }; where keys are unquoted. The less typing the better.

However, PHP allows me to do this:

$keyName = "bar"; $array = array($keyName => "baz");

So in that instance it makes sense to force people to quote their keys. Also, bar or baz could be constants.

Re: PHP Short Syntax for Arrays: developers say no.

#69
post #5

I've been wanting this for a long time, seems like a no brainer to me. It'd be nice to add some of the nice syntactic sugar that other languages have. Kinda strange that they have both readable and unreadable listed as both pro and con...

I don't think that a concise method of working with arrays should be thought of as syntactic sugar, not if you mean it in a pejorative way. I found array_map, array_filter, array_key_exists, array_this, array_that painful to write, but never felt that I was gaining any sort of readability for it.

Wouldn't it be nice if PHP arrays acted as objects and all of those functions were methods?

$newArray = $array->map("function_name");

Not gonna happen, but would be nice. Any extensions doing this?

Re: PHP Short Syntax for Arrays: developers say no.

#70

I would give up hope for the ability to have a short syntax for arrays (or lots of other syntactical pleasantries) if the core team would please finally implement named arguments.

Could you explain what you mean by this?

edit: ahh, found it. Knew what it was, but not what it was called: http://en.wikipedia.org/wiki/Keyword_argument

Would definitely be a solution to PHP's ridiculous argument ordering inconsistencies.

Post reply on HN