> Le 27 févr. 2023 à 23:36, Karoly Negyesi <kar...@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, naitsi...@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
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to