Re: GOTO operator

From: Date: Sat, 31 Jul 2004 00:42:38 +0000
Subject: Re: GOTO operator
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-11741@lists.php.net to get a copy of this message
----- Original Message ----- From: "Andi Gutmans" <andi@zend.com> To: "Edin Kadribasic" <edink@emini.dk>; "Zeev Suraski" <zeev@zend.com> Cc: "Jeff Moore" <jeff@procata.com>; <ilia@prohost.org>; <internals@lists.php.net> Sent: Friday, July 30, 2004 4:13 PM Subject: Re: [PHP-DEV] GOTO operator > 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; > } edin didn't copy that from my mail, but do_stuff() was meant to be a placeholder for an arbitrary amount of code, even inline. what happens if do_stuff() is a while loop, or if do_more_stuff() is actually 20 lines of relatively strongly nested code? this do-while kludge gets very hairy very fast. i'm somewhat confuzzled why you, of all people, are advocating such mutilation of do-while(), which is *abuse* of the construct. mutilating one construct to emulate another construct, which won't be implemented because it could be abused and mutilated, just doesn't compute for me. i am onboard with the no-goto-out-of-local-scope argument, which the do-while() kludge imposes as well. no reason this limitation can not be implemented, if it isn't already (it is afair), in the patch. paul

« previous php.internals (#11741) next »