|
|
|
|
|
by the_duke
2552 days ago
|
|
This looks pretty much exactly like the old try!(expr) macro in Rust, which has since been replaced with the postfix `?` operator. One crucial difference is that the proposal uses a named `err` return value that can be manipulated in defer. This is supposed to allow cleanup and wrapping of the error type. Rust solves wrapping is by allowing auto-conversion between error types (if they implement it). My first intuition is that it would be an improvement over omni-present `if err != nil {}`, but it feels somewhat awkward and tacked on. Especially the mutable `err` return value. Of course there also was a reason why try! was replaced with `?`: awkward nesting and chaining. Go would have the same problem. |
|
Thanks to tuple returns being a bolted-on afterthought on the language, Go already features awkward and cumbersome nesting and chaining!