for / while else doesn't make sense

Rustom Mody rustompmody at
Wed Jun 15 08:44:13 EDT 2016

On Wednesday, June 15, 2016 at 5:57:51 PM UTC+5:30, BartC wrote:
> On 15/06/2016 12:19, Rustom Mody wrote:
> > On Wednesday, June 15, 2016 at 8:42:33 AM UTC+5:30, Steven D'Aprano wrote:
> >> Sort of. A break is a jump, and a goto is a jump, but apart from that,
> >> they're not really the same thing. A goto can jump (almost) anywhere.
> >> Depending on the language, they can jump into the middle of functions, or
> >> into the middle of loops. That's what makes them powerful enough to break
> >> compositionality. But break can only jump to a single place: to the
> >> statement that follows the for...else compound statement. It's more like a
> >> return than a goto.
> >
> > I thought there'd be many examples for showing that break is just goto in disguise... Evidently not
> >
> > So here is an example in more detail for why/how   break=goto:
> >
> >
> That example is nothing to do with break vs. goto. You've just replaced 
> an erroneous goto with an erroneous break.

Precisely the point -- that that erroneous goto could be an erroneous break
with minor changes to the code (One needs to be inside a break-able statement
like for/while (or for C do/switch)

> It's to do with C (or C-like syntax if not C) using braces for compound 
> statements at the same time as making them optional for a single statement.
> With the wrong indentation applied, that sort of error can easily be 
> missed. Some tools may be able to pick that up.
> (Another kind of error (C seems to have plenty of capacity in this 
> regard!) is forgetting the */ in a /* ... */ comment. Then code is 
> mysteriously ignored until the end of the next /* ... */ comment. 
> Although a syntax-highlighting editor will pick that up more easily.)

As the links point out there can be any amt of post-mortem analysis
- gcc silently stopped dead code warnings
- the misleading indent -- could be detected by tools
- etc

Doesnt change the fact that that misplaced goto could be a misplaced break
And either did/would JUMP OVER critical code wrongly

A rose by any name smells sweet
A goto by any name goes-to

More information about the Python-list mailing list