# extract(EXTR_REFS) and pass-by-reference

- Thread: https://externals.io/message/14260
- Original archive: https://news-web.php.net/php.internals/14260
- Started by Moriyoshi Koizumi on 2005-01-02T06:35:05+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #14260 — Moriyoshi Koizumi — 2005-01-02T06:35:05+00:00

URL: https://externals.io/message/14260#14260

Hi there,

I'm now looking into the three `extract()` bugs related to
each other, namely bug #25708, bug #29493 and bug #31213.

It turned out after all that these problems are caused
by a inevitable zval separation on sending arguments
to the function and there seems to be no feasible workaround
for now. I got stuck with a couple of mentioned ways that fix
the problem just partly, not entirely.

a. Specify first_arg_force_ref to PHP_FE(extract).
   This will cause the engine to yell a 
only-variables-can-be-passed-by-reference!
   when you directly pass a scalar (temporary variable) to it.

b. Turn on allow_call_time_pass_by_reference.
   This is anyway deprecated, but looks like the best way around from the
   my point of view.

Any suggestions will be appreciated.

Moriyoshi

---

## #14262 — Marcus Boerger — 2005-01-02T12:23:17+00:00

URL: https://externals.io/message/14260#14262 · In reply to: #14260

Hello Moriyoshi, Hello Andi

Sunday, January 2, 2005, 7:35:05 AM, you wrote:

> Hi there,

> I'm now looking into the three `extract()` bugs related to
> each other, namely bug #25708, bug #29493 and bug #31213.

> It turned out after all that these problems are caused
> by a inevitable zval separation on sending arguments
> to the function and there seems to be no feasible workaround
> for now. I got stuck with a couple of mentioned ways that fix
> the problem just partly, not entirely.

> a. Specify first_arg_force_ref to PHP_FE(extract).
>    This will cause the engine to yell a 
> only-variables-can-be-passed-by-reference!
>    when you directly pass a scalar (temporary variable) to it.

> b. Turn on allow_call_time_pass_by_reference.
>    This is anyway deprecated, but looks like the best way around from the
>    my point of view.

> Any suggestions will be appreciated.

> Moriyoshi


while i tried to improve performance of the array functions i developed a
new pass type - pass as const which doesn't touch the passed variable at
all and is compatible with temp vars, too. Maybe your problem here is a
reason to really implement that. Andi what do you think?

-- 
Best regards,
 Marcus                            mailto:helly@php.net

---

## #14273 — Moriyoshi Koizumi — 2005-01-04T09:26:50+00:00

URL: https://externals.io/message/14260#14273 · In reply to: #14262

> while i tried to improve performance of the array functions i 
> developed a
> new pass type - pass as const which doesn't touch the passed variable 
> at
> all and is compatible with temp vars, too. Maybe your problem here is a
> reason to really implement that. Andi what do you think?

I think the feature you are proposing will likely be necessary either 
way.
It can also make the output of `debug_zval_dump()` reliable as
implicit separation of zval instances results with bogus reference
counts.

Moriyoshi
