Re: Draft RFC: foreach iteration of keys without values
| From: | Chase Peeler | Date: | Wed, 02 Sep 2020 13:35:23 +0000 |
| Subject: | Re: Draft RFC: foreach iteration of keys without values | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111780@lists.php.net to get a copy of this message | ||
On Wed, Sep 2, 2020 at 9:16 AM Josh Bruce <josh@joshbruce.dev> wrote:
>
> > On Sep 2, 2020, at 6:27 AM, Dik Takken <dik.takken@gmail.com> wrote:
> >
> > On 02-09-2020 12:48, Olle Härstedt wrote:
> >> An alternative syntax would be
> >>
> >> foreach($iterable as $key => _) { ... }
> >>
> >> Using underscore as a way to signal "I don't care about this value".
> >> Same could be possible with list destructoring, like
> >>
> >> [_, _, $something] = foo();
> >>
>
> Swift also uses the underscore in places.
>
> >> 1. It is currently a valid constant name (BC break)
>
> I can name a constant an underscore??
>
> Does anyone actually do this??
>
> I guess I’m asking how impactful the break would be considering most magic
> things start with double underscore and I haven’t seen many people using
> the single underscore to represent instance variables anymore.
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>
Isn't the underscore an alias for gettext()?
--
Chase Peeler
chasepeeler@gmail.com