Re: [RFC] Pipe Operator

From: Date: Tue, 17 May 2016 13:08:08 +0000
Subject: Re: [RFC] Pipe Operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-93374@lists.php.net to get a copy of this message
On 17/05/2016 13:48, Jesse Schalken wrote:
On Tue, May 17, 2016 at 9:14 PM, Rowan Collins <rowan.collins@gmail.com <mailto:rowan.collins@gmail.com>> wrote:
    To reiterate my comments from earlier in the thread, I think the
    "$id = $id" looks really weird here, and spoils the step-by-step
    layout - and, in this case, the symmetry.
We have the same thing already when chaining methods on value/immutable objects, like with PSR-7:
    $message = $message
        ->withHeader('foo', 'bar')
        ->withAddedHeader('foo', 'baz');
So depending on often that pattern is used, many are probably already used to seeing "$var = $var ....", myself included.
A fair point. Although you could of course combine OO chaining with syntax chaining: $message
    ->withHeader('foo', 'bar')
    ->withAddedHeader('foo', 'baz')
    |=> $message;
The longer the chain, the more awkward it is to rewind to the beginning to find where the result is being used / saved. See also my earlier post where I went into why a tail assignment would improve the ability to debug pipes, and mix them with non-piped code: http://marc.info/?l=php-internals&m=146205812523026&w=2 Again, all of this applies to mixing with existing OO pipes like PSR-7. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#93374) next »