[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [PATCH] experimental php-like 'break N' to break across multiple loops
- From: Karel Tuma <ktuma@...>
- Date: Wed, 1 Nov 2006 18:20:54 +0100
On Wed, Nov 01, 2006 at 03:43:20PM +0100, Paul Hudson wrote:
> I'm not sure this is needed, but if other people disagree :) then I think
> the Perl-esque idea of breaking out to a labelled statement is the way to
yep. what about goto? thats named scope too :)
spaghetti construct will remain spaghetti construct, no matter the
circumstances. (named labels, gotos, numbered breaks...).
named scopes are easier to follow in complicated cases.
> The problem with using numeric levels is that refactoring the code and
> changing the number of nested scopes means looking for and changing any
> "break N" statements, which I think is a likely source of tricky-to-debug
agreed. people must think of it like "skip this number of indentation
levels" (in most cases where loops follow each other). instead of
'reference to named scope which we no longer use'. refactoring
mutli-scope constructs is always tough - starting with locals visibility.
when break N is used the loops are almost always inseparable
(for example, two dimensional array search), otherwise
there would be other way around than using spaghetti code (excluding lambda)
> -----Original Message-----
> From: email@example.com
> [mailto:firstname.lastname@example.org] On Behalf Of Karel Tuma
> hi listers,
> i've found myself doing lot of miserable things today, due to inability of
> to simply break out of multiple nested breakable scopes in one statement.
> finding nothing useful in powerpatches archive i wrote this rather naive
> and unintrusive patch - so there is generally no reason why it shouldn't
> but i've tested it extensively only with various for/while nested loops.
> while foo do
> while bar do
> if baz then eek() break 2 end