So, #PHP has fluent interfaces, but it also can do fluent functions: functions that can be chain called.
As usual, it works but it is a tad cumbersome.
[#]phptip #phptrick
https://php-tips.readthedocs.io/en/latest/tips/fluent_function.html
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy Do you have any thoughts on use-cases for this approach that a recursive function wouldn’t solve? Getting back the function itself doesn’t seem terribly useful, to me. Maybe if the input params are passed by reference?
=> More informations about this toot | More toots from ramsey@phpc.social
@ramsey I don't see anything practical for this: the result extraction is way too cumbersome and un-modern.
Although, the chained calls looks quite nice, and 'fluent function' sounds also terrific.
And, of course, blame @heiglandreas (for inspiration).
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy @ramsey @heiglandreas Changing f($v1, $v2, $v3)
into f($v1)($v2)($v3)
is really just currying.
=> More informations about this toot | More toots from Girgias@phpc.social
@Girgias @ramsey @heiglandreas Now, is that good or bad? (Asking for a friend)...😇
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy @ramsey @heiglandreas It's common in functional programming or if you want to work with higher order functions. It's neither good or bad, just a tool :)
=> More informations about this toot | More toots from Girgias@phpc.social
@Girgias @dseguy @ramsey @heiglandreas If you want some real, this library is full of currying https://github.com/loophp/collection/
If I had to redo it today, I would do it differently. Not that it was not convenient, just that it doesn't really bring some added value.
=> More informations about this toot | More toots from Pol@mathstodon.xyz
@Girgias @dseguy @ramsey @heiglandreas This is curry.
=> More informations about this toot | More toots from derickr@phpc.social
@derickr @Girgias @ramsey @heiglandreas yes, but have you been currying yourself?
=> More informations about this toot | More toots from dseguy@phpc.social
@dseguy @Girgias @ramsey @heiglandreas Not tonight. But likely tomorrow!
=> More informations about this toot | More toots from derickr@phpc.social
@derickr now I want curry...
=> More informations about this toot | More toots from Tylae@phpc.social
@Tylae Nom nom.
=> More informations about this toot | More toots from derickr@phpc.social
@derickr tried out malai kofta. Super yummy.
=> More informations about this toot | More toots from Tylae@phpc.social
@derickr @Girgias @dseguy @ramsey @heiglandreas So is this.
=> More informations about this toot | More toots from Crell@phpc.social This content has been proxied by September (ba2dc).Proxy Information
text/gemini