▲ | mort96 8 days ago | ||||||||||||||||
I'm surprised that the example requires lambdas... What's the purpose of the `|> foo(...)' syntax if the function has to take exactly one operand? Why is it necessary to write this?
Why doesn't this work?
And when that doesn't work, why doesn't this work?
| |||||||||||||||||
▲ | ptx 7 days ago | parent | next [-] | ||||||||||||||||
Apparently "foo(...)" is just the PHP syntax for a function reference, according to the "first-class callable" RFC [1] linked from the article. So where in Python you would say e.g.
PHP requires the syntax
As for the purpose of the feature as a whole, although it seems like it could be replaced with function composition as mentioned at the end of the article, and the function composition could be implemented with a utility function instead of dedicated syntax, the advantage of adding these operators is apparently [2] performance (fewer function calls) and facilitating static type-checking.[1] https://wiki.php.net/rfc/first_class_callable_syntax [2] https://wiki.php.net/rfc/function-composition#why_in_the_eng... | |||||||||||||||||
| |||||||||||||||||
▲ | moebrowne 7 days ago | parent | prev | next [-] | ||||||||||||||||
There is a complementary RFC for partial function application which will allow calling a function with more than one parameter. https://wiki.php.net/rfc/partial_function_application_v2 https://wiki.php.net/rfc/pipe-operator-v3#rejected_features | |||||||||||||||||
▲ | 7 days ago | parent | prev | next [-] | ||||||||||||||||
[deleted] | |||||||||||||||||
▲ | tossandthrow 8 days ago | parent | prev [-] | ||||||||||||||||
It is to interject the chained value at the right position in the function. They write that elixir has a slightly fancier version, it is likely around this, they mean (where elixir has first class support for arity > 1 functions) | |||||||||||||||||
|