err := f()
on err, <single_statement>
on err, return err // any type can be tested for non-zero
on err, return fmt.Errorf(...)
on err, fmt.Println(err) // doesn't stop the function
on err, continue // retry in a loop
on err, goto label // labeled handler invocation
on err, hname // named handler invocation
on err, os.IsNotExist(err): <stmt> on err, err == io.EOF: <stmt> on err, err.(*os.PathError): <stmt> // doesn't panic if not a match on err, <condition>: <stmt> on err: <stmt> // this pair provides if/else in 2 lines
on err := f(), <stmt> // for assignment with single lvalue
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/decc63a5-9e65-4e96-929f-76d44cf19e14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CANfvvbVy1iP8Un8zudCwZhkTg5dQfGCrBkN-0VmFbbK-FgD8dA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
on err, os.IsNotExist(err): <stmt>
on err, err == io.EOF: <stmt>
on err, err.(*os.PathError): <stmt>
on os.IsNotExist(err): <stmt>
on err == io.EOF: <stmt>
on err.(*os.PathError): <stmt>
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8b5380ea-3fa8-4cc4-9094-545271c9467b%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/4Djft8snCjM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/1b7ab9bd-0c1b-4658-8ee2-a36544b58f20%40googlegroups.com.
less stupid the oprator could infer various things based on static rules,very much like value/ptr initialization implies a few static rules.on os.IsNotExist(err): <stmt> on err == io.EOF: <stmt> on err.(*os.PathError): <stmt>
going to turn code into unreadable, fragmented mess
My point is it doesn't fix anything, it doesn't provide any clear benefit... it's an attempt to fix something which works great and is clearly not broken.
So why complicate the language with a new keyword which has really no purpose.
Maybe adding a warning about unhandled errors to VET would be better idea (which would probably be complicated to do properly, but at least it'll have some real, positive effect on code quality).
In my view, saving a few keystrokes is not the reason to support such a test. I've already got an editor snippet that generates a default "if err != nil ... " clause.
So why complicate the language with a new keyword which has really no purpose.As mentioned in the proposal, try is not a new keyword, it's just a new built-in function.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-W50W92FEKhf4tbSR%3D6wFr3Cc5u1QVWu%2BXnwQWpUCaMQw%40mail.gmail.com.
It's not verbosity. It's error handling. And because error handling is
usually not the happy path, it's good when it stands out clearly. That
improves readability as the important part catches attention easier.
Hiding important code in one line instead, or with even using nested
try constructs, makes the important path easier to overlook or to not
be aware of it at all.
It's quite a bit more than a just new function since it brings some new behaviours that we don't have for functions in Go at the moment:1. like panic it interrupts its caller's control flow2. It may only be used within functions/methods that have a particular signature. Presumably it's a compile error to attempt to use it elsewhere.3. It accepts any number of mixed type arguments without boxing into an interface{}
Because given piece of contemporary production code may succeed in
only ONE way, but it may FAIL in many ways.