RE: [PHP-DEV] Function proposal: varset
| From: | Jonathan Bond-Caron | Date: | Thu, 21 Apr 2011 14:49:12 +0000 |
| Subject: | RE: [PHP-DEV] Function proposal: varset | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-51972@lists.php.net to get a copy of this message | ||
On Wed Apr 20 04:41 PM, D. Dante Lorenso wrote:
>
> My proposal was called "filled" since it was the opposite of "empty"
> which already existed. I extended the function to return the first
> non-empty value or null if all values evaluated as empty.
>
> You could use the function like this:
>
> $x = filled($_GET['x'], $obj->something, $default, 'default');
>
> Like I said, though, I don't think this can be done in the language
> because I think they ran out of OPCODES and would have to tear apart
> the whole PHP engine to support such a feature.
>
That's not the reason, there's 127 / 256 opcodes.
So far "filled", "varset", "coallesce", "ifsetor" or any
operator would likely have to manipulate opcodes.
http://php.net/~helly/ze2-ifsetor-20040901.diff.txt
From what I understand, zeev and andi are strongly opposed to adding a new opcode. I'm sure
they have their reasons.
Maybe there's another approach where ~ E_NONE could be passed to zend_error
ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
{
if(type & E_NONE)
return;
}
Then modify to zend_vm_gen.php to pass E_NONE if within 'ifsetor'.
Either way, there's a solution for it, I think the debate is over how it's implemented.
-- Worth reading
https://wiki.php.net/rfc/ifsetor#rejected_features
-- Why?
I think it simply boils down to this:
- PHP *developers* want a function for it.
Derick