Sorry for a bunch of replies that simply have lost a lot of context.. I'll
try to summarize it all here:

> 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

 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

> In my opinion "ideal" here is that our symbol tables are merged, so
> referring to "trim" in any context will resolve to at most one symbol

That sounds like a plan, and if there is a reasonable support for that,
then we could just have array_filter($arr, trim) - then its way better than
my proposal, and should also work with class methods.

> Right click on `function::trim` - Find Usages. Basically allows to find
all
> usages of a given function, including the callback usage.

Yeah, that was part of the idea, the other being to make these callbacks
semantically different from strings. Its just weird that a string is
callable, isn't it?

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

My proposal would not work for methods. function::CustomClass::someMethod -
that doesn't look great at all, at least to me.

On Fri, Oct 26, 2018 at 10:01 PM Crocodile <crocodil...@gmail.com> wrote:

> My proposal would not work for methods. function::CustomClass::someMethod
> - that doesn't look great at all, at least to me.
>
>
> On Fri, Oct 26, 2018 at 6:08 PM David Rodrigues <david.pro...@gmail.com>
> wrote:
>
>> 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
>>
> --
> Best regards,
> Victor Bolshov
>
-- 
Best regards,
Victor Bolshov

Reply via email to