Ard Biesheuvel wrote:
Hi all,

is there a specific reason why nested blocks in switch statements are not supported ? It can be very useful if you want to jump into the middle of the first iteration of a loop (like fetching rows from a result set where the first row might or might not be already present)

Eg.

switch ($i) {

case 0:
    do {
        // iteration
default:
    } while ( /* some condition */ );
}

It looks like using "goto" to me. Messy.
That's probably the reason it is not allowed.

Or maybe other people like myself failed to
understand how it is really useful. Real example
from you would help here.

Anyway, are you really sure you want to do that?

#### (what it would be with "goto") ####
$i=7;
$t=0;
switch($i) {
    case 0:
        do {
            echo "($t)";
            label1:
            echo "[$t]";
        } while(++$t<3);
    default:
        goto label1;
}
####

Just my 2 agoras...

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to