That doesn't work for returning errors, though. What if I wanted to return a wrapped version of the error?
Fair enough, but in that case, the wrapping is implicit and it looks like a twisted version of a try/catch block, something that spreads confusion.
I would prefer something like this:
func main() { check { hex := ioutil.ReadAll(os.Stdin) data := parseHexdump(string(hex)) os.Stdout.Write(data) } handle err { switch err.(type) { case *os.ErrNotExist: // Code... case ...: // ... default: // ... } }
As its more structured, easier to read and less confusing than the draft proposal. Note that the handle could be triggered multiple times just as the original handle version.
But now there's very implicit error checking, you don't know which lines may result in an error, which is something the proposal was trying to avoid.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
That doesn't work for returning errors, though. What if I wanted to return a wrapped version of the error?
Fair enough, but in that case, the wrapping is implicit and it looks like a twisted version of a try/catch block, something that spreads confusion.
I would prefer something like this:
As its more structured, easier to read and less confusing than the draft proposal. Note that the handle could be triggered multiple times just as the original handle version.
But now there's very implicit error checking, you don't know which lines may result in an error, which is something the proposal was trying to avoid.