Ancestors

Toot

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

Descendants

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 dseguy on 2025-01-03 at 21:02

@Girgias @ramsey @heiglandreas Now, is that good or bad? (Asking for a friend)...😇

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

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

@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

Written by Pol Dellaiera on 2025-01-03 at 21:55

@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

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

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

@derickr @Girgias @ramsey @heiglandreas yes, but have you been currying yourself?

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

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

@dseguy @Girgias @ramsey @heiglandreas Not tonight. But likely tomorrow!

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

Written by Tiffany on 2025-01-03 at 21:48

@derickr now I want curry...

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

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

@Tylae Nom nom.

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

Written by Tiffany on 2025-01-04 at 00:24

@derickr tried out malai kofta. Super yummy.

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

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

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

This content has been proxied by September (ba2dc).