Re:The State of Go
by cube2222 on Sunday February 05, 2017 @05:37PM
(#13575111)
You should ALWAYS check the input you get from users. So this really wasn't a good counter argument.
[ Parent
| on HN ]
As I said above, panics should ideally never be able to occur, but be part of the type system.
In languages with dependent types, for example, it’s common to represent a Stack in a way that number and type of elements are stored in the type (so you can’t even pull from an empty stack – that’d be a compile time error).
In the same way, the random number generator should either return an error, or use a number type that can only encode positive numbers as input.
Especially if combined with the interface{} everywhere across the new stdlib functions this all smells very much like C's problems.