Ancestors

Written by dseguy on 2025-01-03 at 17:43

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

=> View attached media

=> More informations about this toot | More toots from dseguy@phpc.social

Written by Ben Ramsey on 2025-01-03 at 20:09

@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

Written by dseguy on 2025-01-03 at 20:56

@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

Written by Gina Peter Banyard on 2025-01-03 at 21:00

@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

Written by Derick Rethans on 2025-01-03 at 21:42

@Girgias @dseguy @ramsey @heiglandreas This is curry.

=> View attached media

=> More informations about this toot | More toots from derickr@phpc.social

Toot

Written by Larry Garfield on 2025-01-03 at 21:56

@derickr @Girgias @dseguy @ramsey @heiglandreas So is this.

=> View attached media

=> More informations about this toot | More toots from Crell@phpc.social

Descendants

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113766654750650167
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
282.707816 milliseconds
Gemini-to-HTML Time
1.184592 milliseconds

This content has been proxied by September (ba2dc).