for / while else doesn't make sense

BartC bc at freeuk.com
Wed Jun 15 08:27:34 EDT 2016


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:
>
> http://blog.languager.org/2016/06/break-is-goto-in-disguise.html

That example is nothing to do with break vs. goto. You've just replaced 
an erroneous goto with an erroneous break.

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.)

-- 
Bartc



More information about the Python-list mailing list