Re: Proposal for php7 class method return

From: Date: Mon, 11 Jul 2016 20:15:30 +0000
Subject: Re: Proposal for php7 class method return
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-94478@lists.php.net to get a copy of this message
On 11/07/2016 20:56, Marco Pivetta wrote:
On 11 July 2016 at 21:51, Jesse Schalken <me@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]

« previous php.internals (#94478) next »