6 ms·
Cool. Now why doesn't PHP join the crowd and do this with arrays already?
by akavlie 16y ago
Cool. Now why doesn't PHP join the crowd and do this with arrays already?
- code_duck 16y agoI absolutely agree. The PHP array instantiation syntax is atrocious... I really dislike '=>'. While they're at it they might as well replace array() with [] and/or {}.
- akavlie 16y agoYep, array() is the icing on the cake. Why is the most common data structure in the language instantiated with a function? I could probably rant on PHP syntax all day long, but it's too off topic here.
- postfuturist 16y agoarray() isn't a function, it's just PHP array literal syntax. $x = array("a" => 100); // legal $y = my_func("a" => 100); // illegal
- akavlie 16y agoYou're right, I was a bit hasty and didn't consider that. It sure does look like a function though, where other languages typically use {} or something similar.
- prodigal_erik 16y agoYeah, call_user_func('strlen', 'hello world') works but call_user_func('array', 'hello world') does not. But for ugly syntax, it's hard to beat the $ sigil being required everywhere for no reason at all (unlike Perl where it actually did something).
- sjs 16y ago$vars remind me of programming mIRC.
- code_duck 16y agoIt's technically a 'language construct', but it sure does seem like a function. Same with PHP's 'list'. It's not good syntax, in my opinion also. It doesn't even seem like syntax!
- tcdent 16y agoLet's throw in support for keyworded arguments while we're at it, too.
- dools 16y agoTo what end?
- lalc 16y ago[NSArray arrayWithObject:notToMentionObjectiveC];
- mkramlich 16y agoshudder Having written and shipped 5+ iPhone apps written in the verbosphemy* that is ObjectiveC, I'm strongly looking forward to being able to do all future iPhone apps in a saner language like JavaScript or Python. If I do them at all. Ever again. In fact it's pretty much a hard requirement. Just after this current one ships. (*: verbose + blasphemy)