DEV Community

Discussion on: My Favorite Go 2 Proposals

Collapse
 
l0k1_smiren profile image
((( лoки )))

More consistency in the stdlib will be very welcome, but really this is not per se Go 2.

I don't like the collect. Right now, using a special function, you can handle all error cases except for when you need to break out of a block or function. A label, which nobody uses, could be used in a closure to skip to the end, but it is ugly. If there was a function to jump back two steps in the stack rather than just one and you have your tidy, structured and most importantly, short error handler. Collect doesn't even address this and if you didn't know you can make one line error handlers already except that trigger a break... A collect statement is far less obvious than breakon(err) or so, and a full handler function can also be written, and it could be completely up to you how to handle it.

Personally, apart from mandatory system specific, 'difficult' to write from scratch algorithms, I often don't even use stdlib that much.

If there was one thing I would like, that would be the option of curly blocks or whitespace delimited a la python. Just look at a typical function in Go. The opening parenthesis distracts (from human scripts we more usually use a : to head a subsection, like Modula and Oberon and go switches)... And then gofmt leaves the closure parenthesis on an otherwise empty line. Gofmt almost already forces the correct indentation anyway (it only allows open and close parentheses on closures very short if blocks).

Other than that, I would like a more concise but unambiguous closure, though on a github issue I posted, someone pointed out the increased ambiguity.

Personally, I will be disappointed if any changes that make the version two are not profoundly powerful, like for statements and strict static typing and interfaces combined.