Re: Idea for better function callbacks (another syntactic sugar)
| From: | Crocodile | Date: | Fri, 26 Oct 2018 20:00:07 +0000 |
| Subject: | Re: Idea for better function callbacks (another syntactic sugar) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-103399@lists.php.net to get a copy of this message | ||
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?
On Fri, Oct 26, 2018 at 6:03 PM Arvids Godjuks <arvids.godjuks@gmail.com>
wrote:
> пт, 26 окт. 2018 г. в 18:57, Kalle Sommer Nielsen <kalle@php.net>:
>
> > Den fre. 26. okt. 2018 kl. 17.43 skrev Larry Garfield <
> > larry@garfieldtech.com>:
> > > 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))
> >
> > I still fail to see why it would be considered to have that over a
> > perfectly encapsulted string for a callback, using a lambda/closure is
> > just an extra runtime call for syntax sugar, that seems poor in my
> > eyes.
> >
>
> Right click on
function::trim - Find Usages. Basically allows
> to find all
> usages of a given function, including the callback usage.
>
> >
> > What would be ideal here, would be for functions to be first class
> > citizens in callback contexts, like in C to avoid the quotation,
> > however it clashes with constants. A hack you can do in userland could
> > be something like:
> >
> > const trim = 'trim';
> > array_filter($names, trim);
> >
> >
> >
> > --
> > regards,
> >
> > Kalle Sommer Nielsen
> > kalle@php.net
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> --
> Arvīds Godjuks
>
> +371 26 851 664 <+371%2026%20851%20664>
> arvids.godjuks@gmail.com
> Skype: psihius
> Telegram: @psihius https://t.me/psihius
>
--
Best regards,
Victor Bolshov