I've never seen a coding guide advocate for setjmp/longjump . And having worked a bit in scheme with first class continuations, they have their beauty, but if you want to understand your code a year after you wrote it, I wouldn't personally recommend it. I don't miss either of these things in Go . In fact, I feel a sense of relief that they aren't.
On Fri, 8 Mar 2019, 15:56 Robert Engels, <reng...@ix.netcom.com> wrote: > I did. No good use for them. People that use them probably also think > exceptions for flow control is a good idea. > > > On Mar 8, 2019, at 8:24 AM, Ian Lance Taylor <i...@golang.org> wrote: > > > > On Fri, Mar 8, 2019 at 5:02 AM whitehexagon via golang-nuts > > <golang-nuts@googlegroups.com> wrote: > >> > >> I'm really liking in Go that I can easily pass bits of code around, > 'closures'? Apologies if I have terminology wrong, since I'm new here. > >> > >> For a typical asynchronous bit of code I like to pass in a 'func' for > what to do with the result, and also a 'func' to handle any errors. > >> > >> I'm struggling to find a clean way to achieve a 'non-local return' i.e. > return from these closures and return the enclosing function too. > >> > >> https://play.golang.org/p/_ANPXKRzibq > >> > >> I had a look at the plan9 assembly stuff, and starting to suspect that > it's probably not possible? > >> > >> So I'm wondering how readable my attempt is. In Objective-C I would > use named parameters here of 'thenDo' and 'elseDo' to help the > readability. And I'm reluctant to try and duplicate that approach using a > struct in Go. But I suppose it's the dangling return that I least like... > > > > You are correct: Go does not support this. > > > > How would a non-local return work from a recursive function closure, > > or a set of mutually recursive function closures? In the general case > > it seems equivalent to an exception with a default handler. Which of > > course you can do in Go using panic and recover, although you have to > > write it yourself. > > > > Ian > > > > -- > > You received this message because you are subscribed to the Google > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to golang-nuts+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.