News for hackers. Stuff that matters.
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:

    $x = new Number(-3.2);
    $y = $x->absolute();
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.
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
Re:Introducing Syngr, my attempt at an Standard Library for PHP by agumonkey on Monday September 23, 2013 @09:00AM (#6430510)
Yes, this is a common source of bugs when you're not sure what is changing. See below, someone suggests to use 'to' and 'as' prefix to convey immutable / mutable methods.