Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:11754 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82661 invoked by uid 1010); 31 Jul 2004 04:18:56 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 82638 invoked by uid 1007); 31 Jul 2004 04:18:56 -0000 Message-ID: <20040731041856.82604.qmail@pb1.pair.com> To: internals@lists.php.net References: <20040729021337.73894.qmail@pb1.pair.com> <1091136355.490.4.camel@localhost> <1091139076.29517.12.camel@blobule.suds> <410991E1.6070000@hristov.com> <1091140927.29516.18.camel@blobule.suds> <41099925.4020700@hristov.com> <4109E7A2.2000701@ppp0.net> <410A140A.3080008@hristov.com> Date: Fri, 30 Jul 2004 21:19:04 -0700 Lines: 88 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2739.300 X-Posted-By: 67.115.107.222 Subject: Re: [PHP-DEV] GOTO operator From: david_c11@sbcglobal.net ("David Chen") "Andrey Hristov" wrote in message news:410A140A.3080008@hristov.com... > Jan Dittmer wrote: > > Andrey Hristov wrote: > > > >> Robert Cummings wrote: > >> > >>> > >>> > >>> Unmaintainable because of the ability to write cryptic code. There's > >>> nothing cryptic about: > >>> > >>> ...code > >>> > >>> goto cleanup: > >>> > >>> ...code > >>> > >>> cleanup: > >> > >> > >> do { > >> .....code... > >> if (something) break; > >> ...code.... > >> } while (0); > >> ...cleanup code... > >> > > > > This works for one level, but imagine: > > > > ... code ... (which exits with goto_out) > > > > if (!alloc x) > > goto out; > > > > ... code ... (which exits with goto_outfreex) > > > > if (!alloc y) > > goto out_freex; > > > > ... code ... (which exits with goto_outfreey) > > > > if (!alloc z) > > goto out_freey; > > > > ... code ... > > > > free z; > > out_freey: > > free y; > > out_freex: > > free x; > > out: > > print bye; > > > > For this you'll need 3 nested do{}while(); loops and your indention is > > so far to the right, that you can barely write more than two more words > > on a line. > > This really looks a lot cleaner with goto. > The way I would do it is to nest it in multiple layers of try/catch try { try { //code }catch(goto_outfreez) { //process //rethrow exception } } catch (goto_outfreey) { //process //rethrow exception } This would look better if I could write this code in an IDE w/ auto-indenting instead of Outlook Express. In terms of visual appearance, you may be right. I'm used to Java now, so I would currently be more accustomed to seeing multiple indentation layers (which is why I'm getting a widescreen notebook soon).