On Jun 10, 2018 10:46 PM, "Hoffman, Zachary Robert" <zrhoff...@ku.edu> wrote:
>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.

Accessing variables by name is a problem for optimimisation and JIT-ing, 
because we lose data-flow dependencies. But, this is not the end of the world. 
We just don't optimize functions that use this "bad" pattern.

Thanks. Dmitry.




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.

Reply via email to