Re: [VOTE] Make compact function reports undefined passed variables
| From: | Hoffman, Zachary Robert | Date: | Sun, 10 Jun 2018 19:46:34 +0000 |
| Subject: | Re: [VOTE] Make compact function reports undefined passed variables | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102219@lists.php.net to get a copy of this message | ||
>The existence of anything that internally relies on
>
get_defined_vars() is a
>blocker for applying further optimisations to the engine (think stack frames),
>which is probably why Dmitry suggested its removal.
I did not know it was an optimization issue. I suppose I could substitute a userland equivalent:
function compact_(array $compact, array $vars)
{
return array_intersect_key($vars, array_flip($compact));
}
which changes A::c() to
function c()
{
$d = $this->d();
$a = pow($d, $d + 1);
$c = $a ^ 0b1100;
$b = $a - $d;
return new B(
compact_(
$this->b(),
get_defined_vars()
)
);
}
That is not so bad. As far as I am concerned, deprecate away.