for / while else doesn't make sense

Random832 random832 at fastmail.com
Wed Jun 15 09:51:37 EDT 2016


On Wed, Jun 15, 2016, at 07:19, Rustom Mody wrote:
> 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

So?

So are loops. So is any "if" statement whose body isn't itself a
one-line goto. Showing that break can be written as a goto is
uninteresting because _any_ form of flow control can be written as a
goto, and in particular it does not establish that break is in any way
less structured than any other constructs that have keywords.

C's for loop:

for(i=0;i<n;i++)
    { body...; }

is syntactic sugar for:

i=0;
loop: body;
inc: i++;
if(i<n) goto loop;
end: ;

[break within body -> goto end;]
[continue within body -> goto inc;]

if(x) true_body; else false_body;

is syntactic sugar for:

if(!x) goto else;
true_body;
goto end;
else: false_body;
end: ;



More information about the Python-list mailing list