Re:Introducing Syngr, my attempt at an Standard Library for PHP
by cabalamat on Monday September 23, 2013 @07:52AM
(#6430200)
AIUI, if I do:
Then not only is $y equal to 3.2, $x is now 3.2 as well. Is this correct? If it is, I think it is non-intuitive.
[ Parent
| on HN ]
Re:Introducing Syngr, my attempt at an Standard Library for PHP
by niteshade on Monday September 23, 2013 @08:14AM
(#6430290)
That is correct. What would you expect it to do?
Re:Introducing Syngr, my attempt at an Standard Library for PHP
by cabalamat on Monday September 23, 2013 @08:40AM
(#6430378)
I would expect $x to remain the same. What's wrong with:
$x = -3.2;
$y = abs($x);
Re:Introducing Syngr, my attempt at an Standard Library for PHP
by agumonkey on Monday September 23, 2013 @08:11AM
(#6430279)
Absolutely.
Re:Introducing Syngr, my attempt at an Standard Library for PHP
by niteshade on Monday September 23, 2013 @08:14AM
(#6430287)
Absolutely non-intuitive?
Re:Introducing Syngr, my attempt at an Standard Library for PHP
by gh0zt on Monday September 23, 2013 @08:30AM
(#6430337)
I think the point here is that you'd have to do something like
this
$x = new Number(1)
$y = clone $x;
$y->absolute();
to work with the absolute value of variable $x without actually changing $x