3 ms·
> But that's up to developer to decide, right? By default panics do work. If I want to call `abort()` on panic, I have to explicitly configure it. Yes and no.
by steveklabnik 6y ago
> But that's up to developer to decide, right? By default panics do work. If I want to call `abort()` on panic, I have to explicitly configure it.
Yes and no. If you need either semantic, you need to specify it, so that when others use your code, they ensure they don't get something that's broken. They "work by default" in the sense that that's the default behavior, but people don't rely on it because unless you say you require it, they may use your code without them.
- vbezhenar 6y agoI guess, you're talking about library code. Libraries should use Result on their API boundaries, that's for sure. If library internals wants to use exceptions-panics, I think that language should allow it, because that's an implementation detail and compiler should allow modules with different panic configurations to co-exist (for example library can use unwinding panic, but as soon as it leaves library boundary, application will abort if it's configured to abort on panic). If it's not possible to implement in a sane way, then I'm OK with libraries forced to use Results as the only error-handling strategy, because I'm more concerned about program code.
- steveklabnik 6y agoIn a systems language, implementation details matter :) You may be compiling with panic=abort because you do not have a useful unwinding implementation, and so a library cannot depend on it existing, even if it's only internal to the library.
- masklinn 6y ago> You may be compiling with panic=abort because you do not have a useful unwinding implementation, and so a library cannot depend on it existing, even if it's only internal to the library. panic=abort is also a somewhat commonly suggested way of slimming down binaries.
- deleted 6y ago[deleted]