I don't think it's quite the same, and although I can agree that short lambdas look better then normal in this context, I would still prefer function::trim
On Fri, Oct 26, 2018 at 5:42 PM Larry Garfield <la...@garfieldtech.com> wrote: > On Friday, October 26, 2018 7:29:46 AM CDT Crocodile wrote: > > Hi internals! > > > > I have this idea of improving the way to specify callbacks for good old > PHP > > functions. For instance, I have this piece of code: > > > > --------------- > > array_filter($names, 'trim') > > --------------- > > > > The callback function name is specified as a string, which makes it > > not-so-obvious, although this is definitely a PHP way. An alternative > would > > be to rewrite this using a lambda: > > > > --------------- > > array_filter($names, function($name) { return trim($name); }) > > --------------- > > > > This is way more wordy, and I bet most of us will go for the first > option. > > > > What if we had a more clear way of specifying those callbacks? I suggest > > the following: > > > > --------------- > > array_filter($names, function::trim) > > --------------- > > > > It is, I believe, more clear then a simple string, just a bit more wordy, > > and since "function" is a reserved word which never had anything to do > with > > "::", the lexer/parser could probably find a way to deal with this kind > of > > syntax (well, honestly, this part is totally unclear for me because I > only > > work with PHP from userland). > > > > Does anyone else find this could be a good addition? Or is it not worth > > considering? Or maybe I am missing some obvious pitfalls? > > > > Cheers, > > Victor > > I believe the proposal for short lambas (which should get resurrected at > some > point) would handle this case well enough as well as help a dozen other > things. To wit: > > array_filter($names, |$x| ==> trim($x)) > > --Larry Garfield -- Best regards, Victor Bolshov