Interesting. I also like the idea of being able define nested enums. Possible syntax:
enum Foo {
Bar,
Wow,
enum Smeg {
Flim,
Flam,
},
}
let x: Foo::Smeg = Foo::Smeg::Flam;
let y: Foo = x;
I donât know why youâd assume such a poor implementation of this idea. The
third level of OpenFileError is NotFoundError which distinguishes between
cases like path/to/file not being openable because to isnât a directory or
because the whole file name was too long. I find it hard to imagine cases where
people would actually care about this distinction. Either way youâre
clearly just dealing with an incorrect file name.
I find it easy to imagine scenarios where people want to recovery from UDP
âdestination unreachableâ errors though. Like, whenever youâre using a UDP
socket to talk to more than one host but you donât want to crash if one of the
hosts is down. That seems like a very typical use case for UDP actually.
The idea is to divide and organize errors based on how people are likely to want
to respond to them. UdpSocket::recv_from errors which donât mean your socket
has become unusable - and after which you can just call recv_from again to
keep receiving packets - seem like a top-level category to me.
I was under the impression that tokio could handle 1,000,000 concurrent
tasks.
You canât think of examples of where programs might want to use all the
resources available? Iâm not saying users shouldnât raise those limits, but
maybe sometimes itâs best for the program to slow down and notify the user
rather than just crashing.
No, but they return something useless, type-wise. To quote myself:
If HashMap::get returned Result<&T, io::Error> do you think people would
reliably handle the case where an entry is missing? Because I think lots of
people would either (a) completely neglect this edge case in their code and
end up throwing io::Errors up the stack instead of doing whatever they should
have done âŚ
Doesnât this sound a lot like Python? Where youâre not forced to consider the
case where an entry is missing and instead you just end up throwing a
KeyError up the stack?
Yes, the second one does. The form of the error guides people in how to handle
it. Thatâs kinda my whole point.