Re: [PHP-DEV] PHP 4.0 Bug #8428 Updated: continue doesn't pass thru a switch statement From: Cynic (cynic <email protected>)
Date: 01/05/01

Forgot to cc the list...

Um, I don't know. This looks to me like trying to hide problems/
inconsistencies/bugs too easily. :) I think it should stay in
the bug realm.

I, just like the other guy, consider this a bug. What good
is continue within switch if it's the same as break, while it's
clearly (meant to be) something different? It could as well
trigger an error: 'use break instead'.

At 05:04 6.1. 2001, Zak Greant wrote the following:
--------------------------------------------------------------
>I should have read your message more carefully :)
>
>I have changed the bug report to be a feature request.
>
> --zak
>
>Cynic wrote:
>> zak,
>>
>> the problem is if != switch in this context.
>> see http://marc.theaimsgroup.com/?l=php-dev&m=97875059607513&w=2
>>
>>
>>
>> At 04:33 6.1. 2001, zak <email protected> wrote the following:
>> --------------------------------------------------------------
>> >ID: 8428
>> >Updated by: zak
>> >Reported By: ocomte <email protected>
>> >Old-Status: Open
>> >Status: Bogus
>> >Bug Type: Unknown/Other Function
>> >Assigned To:
>> >Comments:
>> >
>> >The switch statement is a flow control construct - like for or if.
>Because of this continue behaves within switch like it should in any flow
>control contruct - it skips to the next loop of the construct. However,
>switch does not loop - so continue behaves like break.
>> >
>> >If you would like to use a continue embedded in a switch statement to
>continue past a loop in an outside control construct, specify how many
>levels you would like continue to break out of.
>> >
>> >Try these examples to see what I mean:
>> >
>> ><pre>
>> ><?php
>> > for ($i=0; $i<5; ++$i)
>> > {
>> > switch(1)
>> > {
>> > case 1:
>> > continue 2;
>> > break;
>> > }
>> >
>> > echo "Should be skipped";
>> > }
>> >
>> > // Should not output anything
>> >
>> > for ($i=0; $i<5; ++$i)
>> > {
>> > for ($z=10; $z>5; --$z)
>> > {
>> > switch(1)
>> > {
>> > case 1:
>> > continue 2;
>> > break;
>> > }
>> > echo "\$z=$z\n";
>> > }
>> > echo "\$i=$i\n";
>> > }
>> >
>> > /*
>> > Should output:
>> > $i=0
>> > $i=1
>> > $i=2
>> > $i=3
>> > $i=4
>> > */
>> >?>
>> >
>> >
>> >
>> >
>> >Previous Comments:
>>
>>---------------------------------------------------------------------------
>> >
>> >[2000-12-26 13:34:59] ocomte <email protected>
>> >in the script :
>> ><?
>> > for($i=0; $i<5; ++$i)
>> > { switch(1)
>> > { case 1:
>> > continue;
>> > }
>> > echo "Not printable";
>> > }
>> >?>
>> >
>> >the string is printed 5 times because the continue statement end the
>switch (like break). In C and C++, and in the PHP manual the continue
>(unlike break) isn't affected by surrounding switch statement and it seems
>logical to me.
>> >
>> >
>>
>>---------------------------------------------------------------------------
>> >
>> >
>> >Full Bug description available at: http://bugs.php.net/?id=8428
>> >
>> >
>> >--
>> >PHP Development Mailing List <http://www.php.net/>
>> >To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>> >For additional commands, e-mail: php-dev-help <email protected>
>> >To contact the list administrators, e-mail: php-list-admin <email protected>
>> ------end of quote------
>>
>>
>>
>> ____________________________________________________________
>> Cynic:
>>
>> A member of a group of ancient Greek philosophers who taught
>> that virtue constitutes happiness and that self control is
>> the essential part of virtue.
>>
>> cynic <email protected>
>>
>>
------end of quote------

____________________________________________________________
Cynic:

A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.

cynic <email protected>

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>