frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Ask HN: Who else thinks they should add GOTO statements to Python?

2•n1xis10t•11h ago

Comments

tocs3•11h ago
I do not have strong opinions, except to ask why? I use python a lot (recreational these days) and do not miss a GOTO. Maybe though, you have a case I do not run into often.
n1xis10t•11h ago
Well, I suppose I just like them. There has been once or twice when I thought “This would be so much easier with a GOTO” but unfortunately I have no idea what those situations were, and I don’t think I wrote them down anywhere.
ggm•10h ago
I don't think the "considered harmful" says much to the current coder, but I do think throwing out from deep/loop state to a target is an ugly code method which leaves all kinds of problems behind in it's wake.

Early termination of loops, assumptions about the values present, locality of reference, mutated state.

If your problem is speed, I don't think it necessarily is actually more runtime efficient. If your problem is die early, then it loses information an assert() would preserve. If your problem is a dislike of if-elif-elif- then I think you argue more for a case: statement than a GOTO.

I used them enough in the past to suffer the consequences of debugging around them. I don't miss them, they haven't consciously been in my back pocket armory for some time. I'd rather find other ways to fall through/out-of code to a fixed point.

Jtsummers•6h ago
What would be the behavior of goto in Python? Would you have it jump across functions, modules, stay within a particular scope (file or function scope)? How would you ensure it's well-behaved when jumping into a loop body, or out of it? Saying you want it communicates nothing, explain how it would (or could) work so people can judge your idea.
stefanos82•3h ago
There is an April Fools' joke [1] that demonstrate this and I cannot tell it's readable or not...I personally find it confusing in Python, but not in C's case which can make things clearer, if you use it wisely and in moderation!

[1] https://entrian.com/goto/

Tell HN: Mechanical Turk is twenty years old today

73•csmoak•16h ago•47 comments

Doo: A Simple, Fast Programming Language Built on Rust and LLVM

5•nynrathod•3h ago•2 comments

Ask HN: Where to begin with "modern" Emacs?

204•weakfish•1d ago•107 comments

Ask HN: Anyone else use FreePascal as their low level language?

59•rlawson•1w ago•43 comments

Tell HN: Azure outage

881•tartieret•4d ago•804 comments

Ask HN: Who uses open LLMs and coding assistants locally? Share setup and laptop

338•threeturn•2d ago•183 comments

Ask HN: Is Common Crawl used exhaustively by any search engine?

8•n1xis10t•11h ago•1 comments

Ask HN: Why are QR codes not clickable links on browsers?

19•obilgic•16h ago•12 comments

Ask HN: Alternatives to Clay for Enrichment?

3•Poomba•19h ago•4 comments

Ask HN: Self Hostable Alternative to Jsonbin.io?

8•jimmydin7•15h ago•1 comments

Ask HN: Not treated respectfully by colleague – advice?

115•golly_ned•1w ago•125 comments

Tell HN: Twilio support replies with hallucinated features

157•haute_cuisine•4d ago•40 comments

Ask HN: Who else thinks they should add GOTO statements to Python?

2•n1xis10t•11h ago•5 comments

Ask HN: Why I rarely see game dev startup here?

19•blindprogrammer•2d ago•9 comments

Ask HN: What notably hasn't changed in the past 10 years?

14•cjbarber•1d ago•12 comments

Ask HN: Is anybody running a successful non-subscription business?

13•fandorin•3d ago•32 comments

What is the best way to use Claude Code from my phone?

4•tripleyeti•1d ago•5 comments

How are you handling identities for AI agents?

8•andylow•1d ago•7 comments

Scientists can't define consciousness, yet we think AI will have it

15•f_of_t_•2d ago•24 comments

Ask HN: Does anyone else with astigmatism not like dark-mode?

10•morkalork•2d ago•16 comments

Tell HN: OpenAI now requires ID verification and won't refund API credits

205•retube•1w ago•121 comments

Ask HN: Is Udacity now geo blocking countries?

5•estebarb•3d ago•0 comments

Ask HN: Is AWS down again?

85•ajdude•6d ago•37 comments

Ask HN: How to deal with long vibe-coded PRs?

7•philippta•5d ago•14 comments

Ask HN: Thoughts on /etc/hosts instead of DNS for production applications?

13•notepad0x90•4d ago•13 comments

You've reached the end!