Skip to content

Comment on A function decorator that rewrites the bytecode to enable goto in Python

Comments

Exceptions are forward gotos. A "while" loop with continue and break is backward goto. The only thing missing is break from nested while. Java has one, called break with label, one of more obscure features of language. So, in a sense, python already does have goto.

All control flow constructs in modern programming languages are about codifying the safe uses of goto and setjmp.

For example defer and friends are goto cleanup; and yield and exceptions are setjmp.

Sometimes a feature of a programming language is about making it really inconvenient to do something you shouldn't be doing

So rust also has goto :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.