On 8 April 2026 17:07:38 BST, Larry Garfield <[email protected]> wrote:

>Switch being considered a looping structure does qualify as a "quirk" in my 
>book.  

I had a look at really old code on https://museum.php.net and from what I can 
make out, PHP/FI 2.0 had single-level "break" only as part of the "switch" 
syntax; there was no way to terminate loops early. PHP 3.0 added a 
general-purpose "break" and "continue", with both keywords taking an optional 
argument - in fact, both were implemented by the same C function. 

The existing use of "break" for switch statements just became part of this more 
general feature. I guess you could argue that that means "treating switch as a 
looping construct", but I honestly can't think what the alternative would have 
been, other than using a different keyword.

If PHP has a "quirk" it is that "break" and "continue" both take a numeric 
argument. Any new use of either keyword would need to deal with that quirk, 
even if "switch" was removed from the language completely.


Rowan Tommins
[IMSoP]

Reply via email to