3 ms·
A type system can refuse to turn a `bytes` into a `utf8str` until it's been appropriately parsed. (It doesn't even need to be a very good or strongly-enforced
by morelisp 5y ago
A type system can refuse to turn a `bytes` into a `utf8str` until it's been appropriately parsed.
(It doesn't even need to be a very good or strongly-enforced type system - Go makes it dangerously easy to convert between `[]byte` and `string` by other-type-system standards, and yet everything works pretty well. It's enough to hitch your thinking and make you realize you need another step.)
- BiteCode_dev 5y agoHow does the type system knows the bytes are utf8 and not CP850?
- morelisp 5y agoThe same way you can parse a string into an integer and it knows you got an either[integer, err].
- deleted 5y ago[deleted]
- BiteCode_dev 5y agoSo it doesn't, and it's not about the type system. Any decode operation in python 3 raise an exception or return string. It's about the runtime error handling making it mandatory to deal with the error and won't let you panic at run time for this specific error.
- morelisp 5y agoI'm sorry you don't see exceptions as part of a type system yet.