Re:Goto in Python
by RussianCow on Monday September 21, 2015 @11:49AM
(#10253060)
How would you expect the second one to work?
[ Parent
| on HN ]
I guess similarly to C:
for i in foo:
print(42)
would be considered equivalent to something like it = iter(foo)
while True:
try:
i = next(it)
catch StopIteration:
break
print(42)
and jumping to print(42) would skip the init and first iteration expression.Of course that's non-obvious behaviour, so in practice you would make it a compile time error. A careful language designer might even decide to not support goto at all. :)