Re: Seeking 'coalesce' php internal function
| From: | D. Dante Lorenso | Date: | Thu, 04 May 2006 01:33:17 +0000 |
| Subject: | Re: Seeking 'coalesce' php internal function | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-23142@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf wrote:
Not sure what you guys are talking about. ?: is on the roadmap. -RasmusOk. That has some signs of hope. What is ?: exactly, though. I searched '?:' and yeah, good luck with that in documentation. It doesn't smell like it supports all the specifics that 'filled()' does. Am I supposed to do this: $value = $x ?: $y ?: $z ?: $default; And no warnings will be thrown for $x, $y, and $z not existing? Did you see my post about 'filled()'? http://news.php.net/php.internals/23132 Honestly, I'm happy to see '?:' because that's better than nothing, but I think filled() is more like empty() and would be a better implementation. If you want to look at the language from a consistency point of view '?:' is very PERL-like whereas filled(...) is PHP-like: PERL-like: $x ~= s/\s+//; $x = $a ?: $b ?: $c; PHP-like: $x = preg_replace("/\s+/", "", $x); $x = filled($a, $b, $c); In my PHP zen world, empty() and filled() are friends. Ok, I've been selling 'filled()' for a while now. Can we reverse the sell and try this .. why SHOULDN'T filled() be added to the language? Dante