Re: Re[2]: [SMARTY-DEV] mixing of asign() and assign_by_ref() overwrites external vars
| From: | boots | Date: | Mon, 07 Jun 2004 21:58:31 +0000 |
| Subject: | Re: Re[2]: [SMARTY-DEV] mixing of asign() and assign_by_ref() overwrites external vars | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-2409@lists.php.net to get a copy of this message | ||
--- Dmitry Koteroff <delete@koteroff.ru> wrote:
B> The whole point of assigning-by-reference is that you are
B> aliasing the variable as opposed to making a copy. When you
B> assign $test_2 = $test, even though you don't do it
B> by-reference, you are making a copy of an object that contains
B> references. When you alter the reference (even in the copy),
B> you necessarily alter the original var. This is the way PHP
B> works and I don't think it implies any problems with the
B> Smarty semantics.
D> I still don't understand why don't you want to appli little patch
D> which was attached above. It is fully transparent,
D> back-compatible and add new feautures (including fix of
D> unsuspected behavour with assign after assign_by_ref).
Hi Dmitry,
My reasons are thus:
1) I don't agree that it is unsuspected; it follows the PHP4 paradigm.
2) I don't agree that it is transparent: messju already pointed out the
problem with deprecated pass-by-reference.
3) I agree with Monte's sentiment: don't fix what isn't broken. In my
last post, I show the standard work-around for getting the behaviour
that was desired in the case originally given. It uses an existing API
call which merely wraps what you would have to do with straight PHP:
use unset().
4) You are overloading the meaning of assign() to allow
pass-by-reference whereas the Smarty API already decided long ago to
break that into a different API call, namely assign_by_ref(). I think
it is more confusing when you have two methods to do ostensibly the
same thing.
Cheers,
xo boots
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/