[PHP-DEV] Re: re-referencing and how we could enable this *without* pointers From: André Langhorst (waldschrott <email protected>)
Date: 08/19/00

> I do not get what you are meaning to do. There's absolutely no way to know
> which variable in which symbol table user had that is linked to your
> variable "$foo". So, you _can not_ relink *that* unknown variable to be
> reference to any other variable, because this would require knowing
> calling symbol table _and_ name of the variable in that sumbol table,
> which is (at least with current PHP) you have absolutely no way to know.

<thoroughly>

hey, it´s a kind of tweaking, you´re simply bypassing that lack of information,
and if I´m right that ref-counting prevents us from performance hurts,
it´s a very good solution then - it´s not the the way you´d expect,
in fact the expression i mentioned is a short form for a funtion doing this

it´s the twisted way, you´re doing it reversed, it´s not very complicated but effective

// start logic
function re_link(&$to_merge_with,&$get_value_from) {
$tmp=$get_value_from; // save value
$get_value_from=&$to_merge_with; // now you´ve linked all the three but lost the value
$get_value_from=$tmp; } // restore the value
// end logic

// start testcase
$tmp=5;
$tmp2=&$tmp;
$tmp3=&$tmp;
$tmp4=&$tmp;
$variable_which_is_now_a_reference_2_tmp=&testcase($tmp);

echo $tmp;
?><BR><?php
echo $tmp==$variable_which_is_now_a_reference_2_tmp;

function &testcase(&$tmp) {
$variable_which_would_like_to_be_a_reference_2_tmp='foooo';
re_link($tmp,$variable_which_would_like_to_be_a_reference_2_tmp);
return $variable_which_would_like_to_be_a_reference_2_tmp; }
// end testcase

so far we´ve reached *everything* we wanted to do, *without*
"knowing which variable in which symbol table user had that is linked to variable"
we´ve linked *all* variables and assigned them "foreign"-value

and to avoid the need to let the user create this function every time, we´re doing
it transparently with a construct *like*
$new_ref&=&$merger_ref;
or
$new_ref&=$merger_ref;

best regards ;)

-- 
o----------0-¬---------O-·---¬----o---®-----o o    O   °       .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0  O °     ¤  °        ·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ ° o © °   .  ·
| psychedelic experience |  gott <email protected>  | O   ° o           °
o-¬--o--0-----©-·--O-----o-----0-¤----------o  0 °  · °  .  ¤ ·

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>