Earlier quoted context omitted.
It's not quite what you're asking for, but there is a way to handle array results from functions where you know the number of elements that will be returned. For example: // explode splits the string on the provided boundary // and returns an array containing each segment. // using list() we can assign the two segments to two // variables within the same statement $size = "1000x1000"; list( $width, $height ) = explod…
Ah yes, I love nothing more than functions on the left side of assignment. Edit: Yes, it is a special form, but its still irregular, and that makes it shitty.
Short array syntax finally in PHP 5.4
31–40 of 80 posts
Re: Short array syntax finally in PHP 5.4
#32But PHP isn't a transmitted language like javascript, why even bother? It will only make the parser slower?
They're trying to be nicer to the humans. (Though IMO, any human who wanted to be kind to himself would just not use PHP to begin wtih.)
Re: Short array syntax finally in PHP 5.4
#33Re: Short array syntax finally in PHP 5.4
#34What about short object declaration syntax:
$obj = { param:'blah' };
PHP already has stdClass, so I doubt it would take much of a parser change to implement that.
Re: Short array syntax finally in PHP 5.4
#35My big complaint about arrays wasn't declaring them. It was the endless array functions you have to use afterwards. array_push array_pop array_slice array_shift array_unshift array_map array_key_exists It kind of feels like they missed the point, saving 5 characters when you declare the array once, ignoring all of the other operations you do afterwards. And this RFC, simple as it is, took 3.5 years to come to fruitio…
Re: Short array syntax finally in PHP 5.4
#36sigh Can the PHP devs focus on the real problems now? cough Unicode anyone? Ridiculously inconsistent naming of string and array functions? The woefully incomplete and useless STL? The lack of OO in arrays and strings?
Re: Short array syntax finally in PHP 5.4
#37Still strikes me as a useless bit of syntactic sugar. Is it really that much work to write array('foo' => 'bar')? As far as I can tell, writing ['foo' => 'bar'] isn't that much shorter in the first place. sigh Can the PHP devs focus on the real problems now? cough Unicode anyone? Ridiculously inconsistent naming of string and array functions? The woefully incomplete and useless STL? The lack of OO in arrays and strin…
Re: Short array syntax finally in PHP 5.4
#38Earlier quoted context omitted.
Hard to say that it is simple unless you know the internals.
2 lines in the parser: http://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_langua... The RFC ( https://wiki.php.net/rfc/shortsyntaxforarrays ) was actually rejected by the developers, I think it's only really been put in to appease large userland pressure. Find it rather amusing that a 2 change to the parser for an alias would be rejected on 'maintainability' grounds.
Re: Short array syntax finally in PHP 5.4
#39Still strikes me as a useless bit of syntactic sugar. Is it really that much work to write array('foo' => 'bar')? As far as I can tell, writing ['foo' => 'bar'] isn't that much shorter in the first place. sigh Can the PHP devs focus on the real problems now? cough Unicode anyone? Ridiculously inconsistent naming of string and array functions? The woefully incomplete and useless STL? The lack of OO in arrays and strin…
Re: Short array syntax finally in PHP 5.4
#40Still strikes me as a useless bit of syntactic sugar. Is it really that much work to write array('foo' => 'bar')? As far as I can tell, writing ['foo' => 'bar'] isn't that much shorter in the first place. sigh Can the PHP devs focus on the real problems now? cough Unicode anyone? Ridiculously inconsistent naming of string and array functions? The woefully incomplete and useless STL? The lack of OO in arrays and strin…
Hey, I've been complaining about PHP's lack of Unicode support forever. Every time I do, though, an apologist comes out of the woodwork to tell me about the mb_*() functions. Apparently the PHP community is quite comfortable not caring about non-ASCII characters.