What's the meaning of this code? func main() { f := g() f() }
func g() func() { Top: return func() { returnfrom Top, nil} } On Thursday, September 13, 2018 at 3:29:03 PM UTC-4, Scott Pakin wrote: > > I recently added to the Go 2 Error Handling Feedback > <https://github.com/golang/go/wiki/Go2ErrorHandlingFeedback> page my > thoughts on how to improve upon the draft design for error handling > <https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling.md> > : > > Go 2 error handling based on non-local returns > <https://gist.github.com/spakin/86ea86ca48aefc78b672636914f4fc23> > > > You can read the details by clicking on that link, but the idea is to > introduce a single new keyword, returnfrom, that a function can use to > return from a lexically enclosing scope. Thus, one can define an error > handler—as an ordinary function, not a handle. One can check any status > type—unlike check, which is limited to error. And one can stack error > handlers, but this is explicit, not implicit as in handle. > > Personally, I find returnfrom to be a better solution than check/handle > while still retaining the key benefits of that approach. See what you > think. > > — Scott > > -- 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.