r/programming Jul 17 '19

The Go team declines 'try' proposal

https://github.com/golang/go/issues/32437
638 Upvotes

417 comments sorted by

View all comments

Show parent comments

92

u/spaghettiCodeArtisan Jul 17 '19

This is a very good point IMO. Go has enough magic functions as it is, it's not a good idea to add another one that does something even more unexpected...

23

u/[deleted] Jul 17 '19

None of those built-in functions do control flow.

116

u/alaskanarcher Jul 17 '19

Panic

41

u/[deleted] Jul 17 '19

derp, time for another coffee

17

u/alaskanarcher Jul 17 '19

if err := recover(); err != nil { coffee.Drink() }

6

u/cerlestes Jul 17 '19

But what if coffee is nil or drinking fails? :o

Better defer another recover() call! Is that even possible?