Re: Steal labelled break and continue from zig?
| From: | Claude Pache | Date: | Tue, 28 Feb 2023 09:22:05 +0000 |
| Subject: | Re: Steal labelled break and continue from zig? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-119612@lists.php.net to get a copy of this message | ||
> Le 27 févr. 2023 à 23:36, Karoly Negyesi <karoly@negyesi.net> a écrit :
>
> Hello,
>
> As I was reading
> https://kristoff.it/blog/zig-multi-sequence-for-loops/ I
> found a very nice trick which in PHP would be:
>
> foo: while ($i--) {
> if ($ % 2) break foo;
> }
>
> What do you think?
>
Yes, I use sometimes this feature in JavaScript (which allows to “break” any labelled block, not
just loops).
That said, it is somewhat less needed, since we have
goto in PHP. But it would be
nevertheless welcome. (I won’t go as far as deprecating break 3;, although I tend to
avoid such code.)
> Le 28 févr. 2023 à 08:45, naitsirch@e.mail.de a écrit :
>
> Unfortunately goto does not have a good image ;-)
>
The bad reputation of goto is indeed harmful. I heavily use goto in PHP
because I like structured programming. :-)
—Claude