Re: GOTO operator

From: Date: Sat, 31 Jul 2004 20:35:51 +0000
Subject: Re: GOTO operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-11731@lists.php.net to get a copy of this message
Andi Gutmans wrote: so you are replacing the question "where does it go to" that can be answered with a string search wiht "where does it break to" This one alone justifies at least labeled breaks as JAVA has them and that are a kind of restricted GOTO (as you can also break out of an if) The JAVA approach is even superior to PHPs "break n;" where n has to be an integer and you have to be very carefull to not wrap another loop around the break but within the loop supposed to be broken
At 09:53 PM 7/30/2004 +0200, Edin Kadribasic wrote: function pseudocode() {
    $a=allocate_resource_z();
    $b=allocate_resource_y();
do {
    $res=do_stuff();
    if(!$res)
        break;
    $c=allocate_resource_x();
    $res=do_more_stuff();
    if(!$res)
        break;
    $d=allocate_resource_foo();
    $res=do_even_more_stuff();
    if(!$res)
        break;
    return true;
} while (0);
    free_resouce($a);
    free_resouce($b);
    if(isset($c)) free_resouce($c);
    if(isset($d)) free_resouce($c);
    return false;
}
-- Hartmut Holzgraefe <hartmut@php.net>

« previous php.internals (#11731) next »