On Thu, Jul 21, 2016 at 6:59 AM, Rowan Collins <rowan.coll...@gmail.com> wrote:
> On 21/07/2016 00:42, Sara Golemon wrote:
>>
>> With the branching of 7.1, and after some reflection on the previous
>> feedback, I'd like to reopen discussion of the Pipe Operator RFC
>> https://wiki.php.net/rfc/pipe-operator which I had previously put on
>> hold.  I've changed much of the argument wording of the proposal, but
>> not the substantive feature set.  If you still feel it's unworkable,
>> I'd like to encourage you to respond with what you think would make it
>> workable (if anything).  Thanks.
>
> It looks like the examples are all still function calls. Could you clarify
> what expressions would be acceptable on the right-hand side?
>
Any non-terminal expression.

> In particular, can I assign to a variable at the end of the pipe?
>
> foo() |> bar($$) |> $result = $$;
>
Sure.  ($result = $$) is an expression which returns the assigned
value, so it's a valid non-terminal.

$alsoResult = foo() |> bar($$) |> $result = $$;
var_dump($alsoResult === $result); // bool(true)

> As discussed before, I think pipes would be most useful if values could
> "exit on the right". For which I would also like to be able to do this:
>
> foo() |> bar($$) |> return $$;
>
Are you picturing the return statement returning from the current
function? Or "returning" from the current pipe chain?

I think you mean the former, in which case I'd ask how that'd better/worse than:

return foo() |> bar($$);

> (Or, as discussed, special syntax for one or both of these.)
>
As above, I don't think special syntax adds anything for either of these cases.

-Sara

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

Reply via email to