On Thu, Sep 21, 2017 at 5:13 PM, Stanislav Malyshev <smalys...@gmail.com> wrote: > It'd be also nice then if we could have some syntax that allowed us to > refer to functions/methods as callables - mostly for the benefit of the > code readers and IDEs. I.e. you can do "hello" |> "strtoupper" and it's > fine but it is not at all intuitive what you're doing sending one string > into another. Same with "hello" |> [$this, 'bar']. Now, if we could do > something like this: > "hello" |> &{strtoupper} > "hello" |> &{$this->bar} > Super-hacky implementation (that I wouldn't want to merge, but it shows the syntax at work).
https://github.com/php/php-src/compare/master...sgolemon:lambda which provides a form of both short-closures and partial functions. Combined with also-super-hacky pipe diff from earlier, you get: $x = "Hello" |> &{strtoupper($0)} |> &{ $0 . "world" } |> &{strrev($0)}; var_dump($x); // string(10) "dlrowOLLEH" -Sara -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php