On 11/07/2016 20:56, Marco Pivetta wrote:
On 11 July 2016 at 21:51, Jesse Schalken <m...@jesseschalken.com> wrote:

does save the verbosity of repeating a variable name, and often saves a
variable altogether:

$blah = new Blah();
$blah->setFoo(1);
$blah->setBaz(2);
$this->setBlah($blah);


becomes

$this->setBlah((new Blah())
     ->setFoo(1)
     ->setBaz(2)
);


Right: to save one variable assignment you now have 3 function calls. I
think I see your problem (if this is about performance) :-P

Huh? There's exactly the same number of function calls. And who said this was ever about performance?

Again, it's just different syntax for doing things we can already do. Even the object cascade operator is just hiding the assignment to a temporary variable - think of it like post-increment:

$bar = $foo; $foo = $foo + 1;
$bar = $foo++;

$bar = $foo; $foo->inc();
$bar = $foo->>inc();

(I'm not suggesting this is a literal use case for the operator, just highlighting the parallels; please don't start picking at it.)

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to