Em sex, 26 de out de 2018 às 09:30, Crocodile <crocodil...@gmail.com>
escreveu:

> 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)
> ---------------
>

And about methods? How it should works if I wants to call a method from a
custom class? It should be function::CustomClass::someMethod?



>
> 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
> --
> Best regards,
> Victor Bolshov
>


-- 
David Rodrigues

Reply via email to