Re: [Concept] Extension methods

From: Date: Thu, 11 Aug 2022 18:58:30 +0000
Subject: Re: [Concept] Extension methods
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-118419@lists.php.net to get a copy of this message
On Thu, Aug 11, 2022, at 1:51 PM, Alex Wells wrote: > The pipe operator RFC has actually been mentioned before; the short > takeway is: pipe operator works and has a benefit of using existing > functions. The downside is that those are still functions, not methods, > meaning you’ll still be left with [your_type]_ prefixes for > all > function names, unlike extension methods, where you can have multiple > methods with the same name (for different types). This is incorrect, and has been since functions could be namespaced. Please stop repeating this, it is FUD. Also, "existing functions" is also not quite accurate. PIpe worked with any callable; the Partial Function Application RFC was intended to make turning arbitrary functions into callables, which could then be easily piped, but you can also use arbitrary callables, including closures and objects that implement __invoke(). array_map in its current form wouldn't be pipeable anyway as it requires multiple arguments, but higher order functions that are pipe-friendly as trivial to write. (See previous message for a link to many.) --Larry Garfield

« previous php.internals (#118419) next »