Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20882 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80536 invoked by uid 1010); 30 Nov 2005 08:46:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 80521 invoked from network); 30 Nov 2005 08:46:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2005 08:46:14 -0000 X-Host-Fingerprint: 130.94.106.86 cluster04.mxpath.net Received: from ([130.94.106.86:41310] helo=smtp02-02.mxpath.net) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 4A/04-14828-5D66D834 for ; Wed, 30 Nov 2005 03:46:13 -0500 Received: from smtp02-02.mxpath.net (localhost.localdomain [127.0.0.1]) by smtp02-02.mxpath.net (Postfix) with ESMTP id 17A5C24A9 for ; Wed, 30 Nov 2005 08:46:07 +0000 (GMT) X-OrigOutBoundIP: 67.117.184.105 OK Received: from mail (adsl-67-117-184-105.dsl.lsan03.pacbell.net [67.117.184.105]) by smtp02-02.mxpath.net (Postfix) with ESMTP id B506A24A9 for ; Wed, 30 Nov 2005 08:46:07 +0000 (GMT) Received: from Skeeve ([67.117.184.106]) by dplhenterprises.com with MailEnable ESMTP; Wed, 30 Nov 2005 00:46:07 -0800 Message-ID: <009801c5f58a$bb432940$800101df@Skeeve> To: References: <2B.E1.14828.4130D834@pb1.pair.com><000001c5f584$77823f80$e902a8c0@thinkpad> <7f3ed2c30511300025t7ea96e54o6951f5814676067a@mail.gmail.com> Date: Wed, 30 Nov 2005 00:47:44 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1506 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 X-MxpathResult: Normal Delivery Subject: Re: [PHP-DEV] Labeled Break (nothing at all whatsoever to do with GOTO) From: dpatterson@dplhenterprises.com ("David M. Patterson") Not only are labeled breaks more readable, they are far more maintainable, especially when nested. With break NUM, you have to change the NUMs every time you change the nesting. I've shot myself in the foot several times that way. Just my two cents as a long-time PHP user Dave Hannes Magnusson said: > IMO labeld breaks are *alot* more readable then break NUM; On 11/30/05, Dmitry Stogov wrote: > Hi Sara, > > This "break LABEL" construct does exactly the same as "break NUM", > > Also I don't like syntax for loops that you suggested. > I prefer "LABEL: while(1) {...}" instead of while LABEL (1) {...}". > > This construct has logic and make sense, but I am not sure that we should > incrise complication of PHP compiler without any serious benefits. > Readability is the only one benefit of this patch. > > May be I missed something? I didn't look into patch deep. > > Thanks. Dmitry. > > > -----Original Message----- > > From: Sara Golemon [mailto:pollita@php.net] > > Sent: Wednesday, November 30, 2005 4:41 AM > > To: internals@lists.php.net > > Subject: [PHP-DEV] Labeled Break (nothing at all whatsoever > > to do with GOTO) > > > > > > But first, this word from our sponsor: > > Group A wants anything resembling goto to burn in the fires > > of hell Group B wants full non-crippled goto or nothing at > > all Group C wants partial goto (non-backward jumping) or > > nothing at all Groups B and C both (generally) want it called > > either GOTO or JUMP, not BREAK > > > > Since no group this size will ever come to an agreement on > > something this divisive, I'd like to turn the topic to a > > completely different language feature which (might) please > > enough people to get a rousing consensus. > > > > Actual labeled breaks. Not the break+jump that was proposed > > earlier in the guise of a break statement, but an actual > > straightforward, no funny-business labeled break which does > > no more and no less than the current break N; construct, but > > allows the use of identifier labels rather than numbers which > > may change as the result of the addition or removal of break > > containers. > > > > http://libssh2.org/patches/true_labeled_break.diff > > > > Usage: > > > > while FOO ($condition) { > > /* statements */ > > break FOO; > > /* more statements */ > > } > > > > Or a stacked example: > > > > for FOO(;;) { > > while BAR (true) { > > foreach BAZ ($arr as $val) { > > switch Foof ($value) { > > default: > > do Plop { > > break FOO; > > } while (false); > > } > > } > > } > > } > > > > Notes on this implementation: > > > > * Labels can't be repeated in an ancestral line. For > > example, the parser will throw an ERROR on the following: > > while FOO(true) { > > while FOO(true) { > > break FOO; > > } > > } > > > > * Labels can be repeated by siblings. I'm not married to > > this, and it certainly has WTF potential. This behavior is > > easily modified to throw an error. I left it permissable > > because there was no technical reason to disallow it. For > > example, the following is okay: while FOO(true) { > > break; > > } > > while FOO(true) { > > break FOO; > > } > > > > * Labeled breaks also apply to continue; For example: > > foreach FOO($arr as $key => $val) { > > if ($key % 2) continue FOO; > > if (empty(%key)) break FOO; > > } > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php