Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> In synchronous code, you can only return once from a function.

Erm, have you heard a term "continuation" or "call/cc" ("call-with-curent-continuation")? Or "delimited continuations"? Or maybe even "Cont monad"? You should read on them, if you haven't - they are one of the most fundamental and fun concepts I encountered.

But even without those, what you wrote here is false in the presence of generators (which are coming to JS any day now!).

I'd say that returning more than once from function is actually a pretty basic technique which is widely used to implement quite a wide array of different things.



Or, over in C land, setjmp.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: