Re:Declined Proposal: A built-in Go error check function, “try”
by jpittis on Tuesday July 16, 2019 @10:55PM
(#20456011)
Having unwrap() in your Rust code is like littering your code base with panic(). It’s not appropriate to use in most production code, but is convenient in prototypes, examples and tests.
Your example re Go errors is incorrect. The go compiler allows you to ignore errors in returns without any compiler error.
For example
err := doThingThatErrs()
and
doThingThatErrs()
are both valid Go code.
Re:Declined Proposal: A built-in Go error check function, “try”
by edflsafoiewq on Wednesday July 17, 2019 @01:48AM
(#20456836)
There's nothing wrong with unwrap. It's just an assert. Even a[i] is just shorthand for a.get(i).unwrap(). Asserts are definitely appropriate in production code, just not for handling run-time errors.
Re:Declined Proposal: A built-in Go error check function, “try”
by jbverschoor on Wednesday July 17, 2019 @03:20AM
(#20457252)
Then how is this better than anything else? Except for syntactical sugar for:
Try Return [Bla(), null] Catch err Return [null, err] End
I do like this syntax better, bc the different scopes cause a lot of nesting
It's similar in Go since you can't compile with unused variable so you need to explicitly discard the error with _. Ex: result, _ := func() This is for multi-value returns, for single value you can even omit the _
https://golang.org/doc/effective_go.html#blank