Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:20881 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77612 invoked by uid 1010); 30 Nov 2005 08:42:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 77596 invoked from network); 30 Nov 2005 08:42:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Nov 2005 08:42:31 -0000 X-Host-Fingerprint: 195.197.172.116 gw02.mail.saunalahti.fi Linux 2.4/2.6 Received: from ([195.197.172.116:42677] helo=gw02.mail.saunalahti.fi) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id AC/83-14828-6F56D834 for ; Wed, 30 Nov 2005 03:42:30 -0500 Received: from nest.netphobia.fi (YZDCXXXI.dsl.saunalahti.fi [85.76.35.232]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id A29D3D92AD; Wed, 30 Nov 2005 10:42:25 +0200 (EET) Received: from nest.netphobia.fi (nest.netphobia.fi [127.0.0.1]) by nest.netphobia.fi (8.13.1/8.13.1) with ESMTP id jAU8gQOx029168; Wed, 30 Nov 2005 10:42:26 +0200 Received: from localhost (jani@localhost) by nest.netphobia.fi (8.13.1/8.13.1/Submit) with ESMTP id jAU8gQa5029165; Wed, 30 Nov 2005 10:42:26 +0200 X-Authentication-Warning: nest.netphobia.fi: jani owned process doing -bs Date: Wed, 30 Nov 2005 10:42:25 +0200 (EET) Reply-To: Jani Taskinen To: Sara Golemon cc: internals@lists.php.net In-Reply-To: <2B.E1.14828.4130D834@pb1.pair.com> Message-ID: References: <2B.E1.14828.4130D834@pb1.pair.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: Re: [PHP-DEV] Labeled Break (nothing at all whatsoever to do with GOTO) From: sniper@iki.fi (Jani Taskinen) I don't care what kind of GOTO I get as long as I get one. Right now I only see need for the forward jumping version, but I don't mind if you could jump backwards too. :) And I also want VETO on each and every bug report about it. :) If anyone dares to report a bug with goto in it -> automatic bogus. We make it work for the simple usage it's meant for and if someone uses it wrong, too bad. :) And the labeled breaks you suggest now can burn in hell! --Jani On Tue, 29 Nov 2005, 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; > } > > -- Give me your money at @ Donating money may make me happier and friendlier for a limited period! Death to all 4 letter abbreviations starting with P!