On Thu, Jan 19, 2017 at 4:55 PM, Ryan Pallas <derokor...@gmail.com> wrote: > On Thu, Jan 19, 2017 at 4:08 PM, Rowan Collins <rowan.coll...@gmail.com> > wrote: >> >> >> On 19/01/2017 22:17, Ryan Pallas wrote: >> >>> >>> When you say assert the right hand side is callable, does that mean to >>> call an object method, you would do [$obj, 'method']? What about >>> functions, >>> is it just the name like $str |> trim, or is it $str |> trim()? >>> >> >> This is a good point. The difference between the pipe operator as proposed >> by Sara and the combination of two separate operators is that in Sara's >> proposal you'd always write this: >> >> $str |> trim($$) >> >> But in Levi's proposal as I understand it, the right-hand side is not >> syntax, it's just constrained to be callable, so the simpler (but rather >> ugly) form would be: >> >> $str |> 'trim' >> > > See I don't like that at all, I hate having to put functions/methods in > strings, as find usages and refactor tools generally don't find the > strings. But sometimes I have to yield my preference to those who outrank > me (aka those with voting power)
While this would be permitted: $str |> 'trim' So would: $str |> trim($$) I empathize that you don't like string-name callables (I really don't like them either) but this RFC helps avoid the string if you want to. Consider // without my proposal: array_map('trim', $input) // with it: array_map(trim($$), $input) Which makes a bigger difference for namespaced functions: // without my proposal: array_map('namespaced\func\map', $input) // with it (assuming you are in the correct namespace or // did `use function namespaced\func\map`: array_map(map($$), $input) So to summarize, the right-hand-side of `|>` being callable doesn't mean you "have to" put it in a string; you can pair it with `$$` to avoid that. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php