Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20864 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17755 invoked by uid 1010); 30 Nov 2005 01:51:21 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 17740 invoked from network); 30 Nov 2005 01:51:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2005 01:51:21 -0000 X-Host-Fingerprint: 66.11.173.122 unknown Received: from ([66.11.173.122:12240] helo=interjinn.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 0A/22-14828-7950D834 for ; Tue, 29 Nov 2005 20:51:20 -0500 Received: from blobule.suds (blobule.suds [192.168.1.3]) by interjinn.com (Postfix) with ESMTP id AD12A11FB6E; Tue, 29 Nov 2005 20:51:16 -0500 (EST) To: Sara Golemon Cc: internals@lists.php.net In-Reply-To: <2B.E1.14828.4130D834@pb1.pair.com> References: <2B.E1.14828.4130D834@pb1.pair.com> Content-Type: text/plain Organization: InterJinn Message-ID: <1133315514.21940.12.camel@blobule.suds> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5-4mdk Date: Tue, 29 Nov 2005 20:51:54 -0500 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Labeled Break (nothing at all whatsoever to do with GOTO) From: robert@interjinn.com (Robert Cummings) On Tue, 2005-11-29 at 20:40, Sara Golemon wrote: > 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; > } Hello, I represent group B (not in any way officially or anything else that might give my words an iota of weight), but I (*cough cough*) WE think that the above break system would make a terrible system for finite state machines. Additionally at this time I'd like to make clear that we are in support for full uncrippled break WITHIN scope. Group A can feel free to travel to the burning fires of hell and have a barbecue, and group C should join us so that at least they get what they want as a subset. As an aside, from what I've read, the multitude were in favour of unrestricted goto. Quite a few were in favour of none at all (but not as many as in group B) and those in favour of none at all had a large subset that were in favour of unrestricted goto in the event that group B should get their way :) Cheers, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'